Created
November 17, 2016 14:48
-
-
Save oampo/0cf443fc7742a542437a85c6bd15fd01 to your computer and use it in GitHub Desktop.
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 jediName(firstName, lastName) { | |
return lastName.slice(0, 3) + firstName.slice(0, 2); | |
} | |
console.log(jediName('Beyonce', 'Knowles')); | |
function beyond(num) { | |
if (num === Infinity || num === -Infinity) { | |
console.log('And beyond'); | |
} | |
else if (num < 0) { | |
console.log('To negative infinity'); | |
} | |
else if (num > 0) { | |
console.log('To infinity'); | |
} | |
else { | |
console.log('Staying home'); | |
} | |
} | |
beyond(4); | |
beyond(-5); | |
beyond(Infinity); | |
beyond(-Infinity); | |
beyond(0); | |
function decode(code) { | |
var firstCharacter = code.charAt(0); | |
if (firstCharacter === 'a') { | |
return code.charAt(1); | |
} | |
else if (firstCharacter === 'b') { | |
return code.charAt(2); | |
} | |
else if (firstCharacter === 'c') { | |
return code.charAt(3); | |
} | |
else if (firstCharacter === 'd') { | |
return code.charAt(4); | |
} | |
else { | |
return ' '; | |
} | |
} | |
console.log(decode('craft')); | |
console.log(decode('block')); | |
console.log(decode('argon')); | |
console.log(decode('meter')); | |
console.log(decode('bells')); | |
console.log(decode('brown')); | |
console.log(decode('croon')); | |
console.log(decode('droop')); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment