Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- 1.
- Use an array method to remove the last string of the array secretMessage.
- 2.
- Great! You can check your work by logging the .length of the array.
- At this point, the length should be 1 less than the original length.
- 3.
- Use an array method to add the words to and Program as separate strings to the end of the secretMessage array.
- 4.
- Change the word easily to the word right by accessing the index and replacing it.
- 5.
- Use an array method to remove the first string of the array.
- 6.
- Use an array method to add the string Programming to the beginning of the array.
- 7.
- Use an array method to remove the strings get, right, the, first, time,, and replace them with the single string know,.
- Call .splice() like this:
- array.splice(indexToStart, numberOfIndices, 'stringToAdd');
- You can read the documentation on MDN.
- 8.
- On one line, use console.log() and .join() to print the secret message as a sentence.
- Use console.log() and .join(' ') like this
- console.log(array.join(' '));
- Programming is not about what you know, it is about what you can figure out. -2015, Chris Pine, Learn to Program
- */
- 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'];
- let last = secretMessage.pop();
- secretMessage.push('to', 'Program');
- let index = secretMessage.indexOf('easily');
- secretMessage[index] = 'right';
- let first = secretMessage.shift();
- secretMessage.unshift('Programming');
- console.log(secretMessage);
- let index2 = secretMessage.indexOf('get');
- secretMessage.splice(index2, 5, 'know', 'well');
- console.log();
- console.log(secretMessage.join(' '));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement