This file contains 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
function checkCashRegister(price, cash, cid) { | |
const denominationVals = { | |
'ONE HUNDRED': 100, | |
'TWENTY': 20, | |
'TEN': 10, | |
'FIVE': 5, | |
'ONE': 1, | |
'QUARTER': 0.25, | |
'DIME': 0.1, | |
'NICKEL': 0.050, |
This file contains 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
function telephoneCheck(str) { | |
const usPhoneRegex = /^(?:1\s?)?(?:\d{3}|\(\d{3}\))[\s|-]?\d{3}[\s|-]?\d{4}$/ | |
return usPhoneRegex.test(str); | |
} |
This file contains 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
function rot13 (str) { // LBH QVQ VG! | |
const allCapsRegex = /[A-Z]/ | |
let decoded = '' | |
let char = 0 | |
while (char < str.length) { | |
if (true === allCapsRegex.test(str[char])) { | |
decoded += String.fromCharCode( | |
str[char].charCodeAt(0) <= 77 ? str[char].charCodeAt(0) + 13 : str[char].charCodeAt(0) - 13 |
This file contains 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
function convertToRoman(num) { | |
const romanSymbols = { | |
M: 1000, | |
CM: 900, | |
D: 500, | |
CD: 400, | |
C: 100, | |
XC: 90, | |
L: 50, | |
XL: 40, |
This file contains 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
function palindrome(str) { | |
const lettersOnlyRegex = /[a-zA-Z0-9]/g | |
const letters = str.match(lettersOnlyRegex) | |
if (null === letters || 0 === letters.length) { | |
return false | |
} | |
const strippedString = str.match(lettersOnlyRegex).join('').toLowerCase() |
This file contains 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
function strReverse(str) { | |
let reverse = '' | |
let i = str.length | |
while (i-- > 0) { | |
reverse += str[i] | |
} | |
return reverse | |
} |
This file contains 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
server { | |
listen 80 default_server; | |
root /var/www/html; | |
index index.html index.htm index.php; | |
server_name localhost; | |
charset utf-8; | |
location = /favicon.ico { | |
log_not_found off; | |
access_log off; |
This file contains 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
/** | |
* Does this number have 5s? | |
* | |
* @param $number Number to check. | |
* | |
* @since 1.0.0 | |
* | |
* @return bool | |
*/ | |
private function hasFive($number): bool |
This file contains 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
<?php | |
/** | |
* Unit tests for Product of Array Items puzzle. | |
* | |
* @see https://www.codewars.com/kata/product-of-array-items/ | |
* | |
* Requirements: Calculate the product of all elements in an array. | |
* If the array is NULL or empty, return NULL | |
* | |
* @author Caspar Green <[email protected]> |
This file contains 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
<?php | |
/** | |
* Unit tests for Blue and Red Marbles game. | |
* | |
* @see https://www.codewars.com/kata/thinkful-number-drills-blue-and-red-marbles/ | |
* | |
* You and a friend have decided to play a game to drill your statistical intuitions. | |
* The game works like this: | |
* You have a bunch of red and blue marbles. | |
* To start the game you grab a handful of marbles of each color and put them |
NewerOlder