Skip to content

Instantly share code, notes, and snippets.

@oampo
Created November 17, 2016 14:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oampo/0cf443fc7742a542437a85c6bd15fd01 to your computer and use it in GitHub Desktop.
Save oampo/0cf443fc7742a542437a85c6bd15fd01 to your computer and use it in GitHub Desktop.
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