January 2020
Intermediate to advanced
470 pages
11h 13m
English
7.1. Sum as you will: The following exercise will help you understand some of the concepts we dealt with in this chapter, even if you solve it without using any of the functions we looked at. Write a sumMany() function that lets you sum an indeterminate quantity of numbers, in the following fashion. Note that when the function is called with no arguments, the sum is returned:
let result = sumMany((9)(2)(3)(1)(4)(3)()); // 22
7.2. Working stylishly: Write an applyStyle() function that will let you apply basic styling to strings, in the following way. Use either currying or partial application:
const makeBold = applyStyle("b");document.getElementById("myCity").innerHTML = makeBold("Montevideo");// <b>Montevideo</b>, to produce Montevideo ...Read now
Unlock full access