Skip to content

Latest commit

 

History

History
38 lines (32 loc) · 1.12 KB

README.md

File metadata and controls

38 lines (32 loc) · 1.12 KB

TwoTasks

Two easy tasks before you apply for an interview

  1. Задача: не змінюючи логіки, змінити структуру коду, щоби вона відповідала принципу DRY: ctx.prototype.__applyStyleState = function (styleState) { var keys = Object.keys(styleState), i, key; for (i=0; i<keys.length; i++) { key = keys[i]; this[key] = styleState[key]; } }; ctx.prototype.__setDefaultStyles = function () { var keys = Object.keys(STYLES), i, key; // keys of object - object selection for (i=0; i<keys.length; i++) { key = keys[i]; this[key] = STYLES[key].canvas; // field selection } }; ctx.prototype.__getStyleState = function () { var i, styleState = {}, keys = Object.keys(STYLES), key; for (i=0; i<keys.length; i++) { key = keys[i]; styleState[key] = this[key]; } return styleState; };

  2. Друга задача:

const multiply = (a,b,c) => abc; const add = (a,b,c,d,e) => a+b+c+d+e;

const curry = (f) => { /* write your solution here */ }

curry(add)(1)(2)(3)(4)(5) == add(1,2,3,4,5) // should be true curry(multiply)(1)(2)(3) == multiply(1,2,3) // should be true

Гарного дня! :)