Last active
September 7, 2017 13:14
-
-
Save kutyel/64079df4fd773ed7b6233e1241a7aa7f to your computer and use it in GitHub Desktop.
Solutions for the Plain Concepts JavaScript Quizz! ⚡
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ej1 | |
| const list = [1,2,3,4,5,6,7] | |
| const result = list | |
| .forEach(a => a % 2 === 0 ? a : -a) | |
| .filter(b => b > 2) | |
| .some(c => c < 10) | |
| console.log('ej1', result) // throws an error, because of `forEach` | |
| // ej2 | |
| const key = Symbol("${window}") | |
| const inmutable = { | |
| [key]: 'Hello' | |
| } | |
| inmutable[key] = `${'world'}` | |
| console.log('ej2', inmutable[key]) // > 'world' | |
| // ej3 | |
| function* hello() { | |
| yield 'hello' | |
| return 'world' | |
| yield 'hello world' | |
| } | |
| const gen = hello() | |
| gen.next() | |
| gen.next() | |
| console.log('ej3', gen.next()) // > undefined (because it never reaches the second yield) | |
| // ej4 | |
| let arr = [] | |
| for (let i = 0; i < 3; ++i) { | |
| arr.push(i.toString() + (i & 0)) | |
| } | |
| console.log('ej4', arr) // > ['00', '10', '20'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment