-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,38 @@ | ||
# 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) => a*b*c; | ||
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 | ||
|
||
Гарного дня! :) |