Welcome! This is the homework to accompany Girl Develop It LA's JavaScript 201: Intermediate JavaScript class. You can always reference the slides if you get stuck. Commit to spending at least 20 minutes trying to figure out a problem before you peek at the answer. It helps you learn!
1. Always Be True
Write a function that will filter all false and false-y values from an array
Sample Array: [null, 0, 17, false, -27, '', undefined, 47, null]
Expected Results: [17, -27, 47]
2. Secret Code
Write a function that will take an array of letters and convert it to an array of numbers, so that A becomes 1, B becomes 2, C becomes 3, and so on.
Sample Array: ['f', 'a', 'b', 'u', 'l', 'o', 'u', 's']
Expected Result: [6, 1, 2, 21, 12, 15, 21, 19]
3. Squares
Write a function that will take an array of numbers and return an array with the square of each number.
Sample Array: [3, 5, 7, 10]
Expected Results: [9, 25, 49, 100]
4. Secret Code Maker
Write a function that will take a message as a string and convert it to a string of numbers. Leave any spaces or punctuation.
Sample Message: This is a secret message. Don't tell anyone!
Expected Output: 20 8 9 19 9 19 1 19 5 3 18 5 20 13 5 19 19 1 7 5 . 4 15 14 ' 20 20 5 12 12 1 14 25 15 14 5 !
5. Secret Message Decoder
Write a function that will take encoded messages from the previous function and convert them back to the original message.
Sample Message: 20 8 9 19 9 19 1 19 5 3 18 5 20 13 5 19 19 1 7 5 . 4 15 14 ' 20 20 5 12 12 1 14 25 15 14 5 !
Expected Output: This is a secret message. Don't tell anyone!
6. Show object info
Write a function that will print out all the properties of an object to the console.
Sample Object: mabel = {
temperament: 'needy',
fur: 'gray',
eyes: 'green',
sounds: ['meow', 'purr', 'hiss']
};
Expected Output: temperament: needy
fur: gray
eyes: green
sounds: meow,purr,hiss
Hints
- Make sure that you use your browser developer tools.
- Check for errors using console.log() to figure out how far your code makes it and what the values of your variables are along the way.