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
{"lastUpload":"2018-08-16T21:40:14.055Z","extensionVersion":"v3.0.0"} |
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
function convertToRoman(num) { | |
var roman = ""; | |
var decimals = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1], | |
romanNumerals = ['M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I']; | |
decimals.map((number, i) => { | |
while(num >= number) { | |
roman += romanNumerals[i]; | |
num -= number; |
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
function convertToRoman(num) { | |
var roman = ""; | |
while(num !== 0) { | |
if(num < 4) { | |
roman += "I"; | |
num--; | |
} else if(num === 4) { | |
roman += "IV"; | |
num-= 4; |
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
function reverseString(str) { | |
return Array.prototype.reduce.call(str, function(result, c) { | |
return c + result; | |
}, ""); | |
} | |
reverseString("hello"); |
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
function reverseString(str) { | |
var reversed = ''; | |
for(var i = str.length - 1; i >= 0; i--) { | |
reversed += str[i]; | |
} | |
return reversed; | |
} |
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
function reverseString(str) { | |
return str.split('').reverse().join(''); | |
} | |
reverseString("hello"); |
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
function reverseString(str) { | |
var split = str.split('') // splits the string into an array | |
// ["h", "e", "l", "l", "o"] | |
var reverse = split.reverse() // reverses the array in place | |
// ["o", "l", "l", "e", "h"] | |
var join = reverse.join('') // joins all elements together into a string | |
// "olleh" | |