Advertisement
makispaiktis

4. Codecademy Intro - Secret Message (Arrays)

Oct 18th, 2024
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 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'];
  2.  
  3. // Modifications
  4. last = secretMessage.pop();
  5. secretMessage.push('to', 'Program');
  6. index = secretMessage.indexOf('easily');
  7. secretMessage[index] = 'right';
  8. first = secretMessage.shift();
  9. secretMessage.unshift('Programming');
  10.  
  11. // Replace a phrase with a word
  12. to_be_replaced = ['get', 'right', 'the', 'first', 'time'];
  13. LEN = to_be_replaced.length;
  14. index2 = secretMessage.indexOf('get');
  15. secretMessage.splice(index2, LEN, 'know');
  16.  
  17. // Print
  18. console.log(secretMessage.join(' '));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement