Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JavaScript take phone word (vanity number) and return the correct telephone number (function (testFunction) { /* * PHONEWORDS * Write a function that will take

JavaScript take phone word (vanity number) and return the correct telephone number

(function (testFunction) {

/*

* PHONEWORDS

* Write a function that will take a phone word (vanity number) and return the correct telephone number.

* The number pad looks like the following:

* https://en.wikipedia.org/wiki/Telephone_keypad#/media/File:Telephone-keypad2.svg

*

* RULES

* Given a phoneword:

* 1. Ignore any non-alphanumeric characters (), -, etc.

* 2. Keep any existing digits

* 3. Resolve a letter to a number according to the keypad image

* 4. All your code must be contained inside the 'convertPhoneWord' function shown below

* 5. Your ultimate solution must work for ANY phoneword and not simply be implemented to cause the provided tests to pass.

*/

var buttons = ["abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"] //DO NOT MODIFY

// YOU CAN ADD TO AND MODIFY THE CODE BELOW THIS LINE

// |

// V

var convertPhoneWord = function (phoneWord) {

}

// ^

// |

//YOU CAN ADD TO OR MODIFY THE CODE ABOVE THIS LINE

// DO NOT CHANGE ANY CODE AFTER THIS LINE.

// |

// |

// V

//helper functions...do not modify, but you can use them in your code if you wish.

var isDigit = function (character) {

return "0123456789".indexOf(character) !== -1;

}

var isLetter = function (character) {

character = character.toUpperCase();

return "ABCDEFGHIJKLMNOPQRSTUVWXYZ".indexOf(character) !== -1;

}

//Run tests on the function

testFunction(convertPhoneWord); //DO NOT MODIFY

})(testFunction);

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases DeMYSTiFieD

Authors: Andy Oppel

2nd Edition

0071747990, 978-0071747998

More Books

Students also viewed these Databases questions

Question

What attracts you about this role?

Answered: 1 week ago

Question

How many states in India?

Answered: 1 week ago

Question

HOW IS MARKETING CHANGING WITH ARTIFITIAL INTELIGENCE

Answered: 1 week ago

Question

Different types of Grading?

Answered: 1 week ago