June 2018
Beginner
288 pages
6h 31m
English
Here are the solutions to the Exercises, for the Chapter 4, Iterators and Symbols chapter.
| | const letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']; |
| | |
| | for(const [i, letter] of letters.entries()) { |
| | if(i % 3 === 0) |
| | console.log(letter); |
| | } |
| | const numbers = [1, 2, 3]; |
| | |
| | console.log("The Symbol properties in arrays are:"); |
| | |
| | console.log( |
| | Object.getOwnPropertySymbols(Object.getPrototypeOf(numbers))); |
| | class Message { |
| | constructor(text) { this.text = text; } |
| | |
| | [Symbol.replace](word, substitute) { |
| | return this.text.replace(word, substitute); |
| | } |
| | } |
| | |
| | const message = new Message('There are no stupid questions.'); |
| | |
| | console.log('stupid'.replace(message, ... |
Read now
Unlock full access