June 2018
Beginner
288 pages
6h 31m
English
Here are the solutions to the Exercises, for the Chapter 6, Literals and Destructuring chapter.
| | 'use strict'; |
| | |
| | const greet = function(name, gender) { |
| | return `Hello, ${gender === Symbol.for('female') ? 'Ms.' : 'Mr.'} ${name}`; |
| | }; |
| | |
| | console.log(greet('Sara', Symbol.for('female'))); //Hello, Ms. Sara |
| | console.log(greet('Tom', Symbol.for('male'))); //Hello, Mr. Tom |
| | 'use strict'; |
| | |
| | const stripMargin = function(texts, ...expressions) { |
| | const exceptLast = expressions.map(function(expression, index) { |
| | return `${texts[index]}${expression.toString().toUpperCase()}`; |
| | }).join(''); |
| | |
| | const result = `${exceptLast}${texts[texts.length - 1]}`; |
| |
Read now
Unlock full access