This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Return true if the given string is a palindrome. Otherwise, | |
// return false. | |
// A palindrome is a word or sentence that's spelled the same | |
// way both forward and backward, ignoring punctuation, case, | |
// and spacing. | |
// Note | |
// You'll need to remove all non-alphanumeric characters (punctuation, | |
// spaces and symbols) and turn everything into the same case | |
// (lower or upper case) in order to check for palindromes. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Convert the given number into a roman numeral. | |
// All roman numerals answers should be provided in upper-case. | |
function convertToRoman(num) { | |
let thousands = ["", "M", "MM", "MMM"]; | |
let hundreds = ["", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM"]; | |
let dozens = ["", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC"]; | |
let singles = ["", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"]; | |
return thousands[Math.floor(num / 1000)]+ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// One of the simplest and most widely known ciphers is a Caesar cipher, | |
// also known as a shift cipher. In a shift cipher the meanings of the | |
// letters are shifted by some set amount. | |
// A common modern use is the ROT13 cipher, where the values of the | |
// letters are shifted by 13 places. Thus 'A' ↔ 'N', 'B' ↔ 'O' and so on. | |
// Write a function which takes a ROT13 encoded string as input and | |
// returns a decoded string. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Return true if the passed string looks like a valid US | |
// phone number. | |
// The user may fill out the form field any way they choose | |
// as long as it has the format of a valid US number. The | |
// following are examples of valid formats for US numbers | |
// (refer to the tests below for other variants): | |
// 555-555-5555 (555)555-5555 (555) 555-5555 555 555 5555 | |
// 5555555555 1 555 555 5555 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Design a cash register drawer function checkCashRegister() | |
// that accepts purchase price as the first argument (price), | |
// payment as the second argument (cash), and cash-in-drawer | |
// (cid) as the third argument. | |
// cid is a 2D array listing available currency. | |
// The checkCashRegister() function should always return an object | |
// with a status key and a change key. |
OlderNewer