June 2018
Beginner
288 pages
6h 31m
English
Here are the solutions to the Exercises, for the Chapter 11, Exploring Metaprogramming chapter.
| | 'use strict'; |
| | |
| | const printProperties = function(obj) { |
| | for(const property of Object.getOwnPropertyNames(obj)) { |
| | console.log(`${property} is ${obj[property]}`); |
| | } |
| | }; |
| | |
| | printProperties({language: 'JavaScript', typing: 'dynamic'}); |
| | printProperties( |
| | {tool: 'Redux', language: 'JavaScript', purpose: 'transpiler', }); |
| | 'use strict'; |
| | |
| | Number.prototype.percent = function() { |
| | if(this >= 1) { |
| | throw new Error('value should be less than 1'); |
| | } |
| | |
| | return `${this * 100}%`; |
| | }; |
| | |
| | const value1 = 0.35; |
| | const value2 = 0.91; |
| | |
| | console.log(value1.percent()); ... |
Read now
Unlock full access