Skip to content

Instantly share code, notes, and snippets.

@SiimonStark
Created August 24, 2018 15:20
Show Gist options
  • Save SiimonStark/49a2908d33de91a69f8c9971214416f4 to your computer and use it in GitHub Desktop.
Save SiimonStark/49a2908d33de91a69f8c9971214416f4 to your computer and use it in GitHub Desktop.
CodeCademy Project: Secret Message (How to use Array Methods)
let secretMessage = ['Learning', 'is', 'not', 'about', 'what', 'you', 'get', 'easily', 'the', 'first', 'time,', 'it', 'is', 'about', 'what', 'you', 'can', 'figure', 'out.', '-2015,', 'Chris', 'Pine,', 'Learn', 'JavaScript'];
console.log(`Original: ${secretMessage.length}`)
secretMessage.pop();
var add = secretMessage.push('to','program');
console.log(`after add: ${secretMessage.length}`)
var swap = secretMessage[7]= 'right';
console.log(`after swap: ${secretMessage.length}`)
var FiFo = secretMessage.shift();
console.log(`after FiFo: ${secretMessage.length}`)
var pos1 = secretMessage.unshift('Programming');
console.log(`after pos1: ${secretMessage.length}`)
var removal= secretMessage.splice(6,5, 'know, ');
console.log(`after removal: ${secretMessage.length}`)
console.log(secretMessage.join(' '));
/*Output =
Original: 24
after add: 25
after swap: 25
after FiFo: 24
after pos1: 25
after removal: 21
Programming is not about what you know, it is about what you can figure out. -2015, Chris Pine, Learn to program
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment