diff --git a/1-js/01-a/1-a1/1-camelcase/solution/index.js b/1-js/01-a/1-a1/1-camelcase/solution/index.js index a59eae9c..a4edefb4 100644 --- a/1-js/01-a/1-a1/1-camelcase/solution/index.js +++ b/1-js/01-a/1-a1/1-camelcase/solution/index.js @@ -1,2 +1 @@ - -console.log("Hello"); \ No newline at end of file +function camelize(str) {return str.split('-').map((word, index) => index == 0 ? word : word[0].toUpperCase() + word.slice(1)).join('');} diff --git a/1-js/01-a/1-a1/1-camelcase/source/index.js b/1-js/01-a/1-a1/1-camelcase/source/index.js index 69d903f5..c420d5da 100644 --- a/1-js/01-a/1-a1/1-camelcase/source/index.js +++ b/1-js/01-a/1-a1/1-camelcase/source/index.js @@ -1,3 +1,10 @@ function camelize(str) { - /* your code */ -} \ No newline at end of file + return str + .split('-') // разбивает 'my-long-word' на массив ['my', 'long', 'word'] + .map( + // Переводит в верхний регистр первые буквы всех элементом массива за исключением первого + // превращает ['my', 'long', 'word'] в ['my', 'Long', 'Word'] + (word, index) => index == 0 ? word : word[0].toUpperCase() + word.slice(1) + ) + .join(''); // соединяет ['my', 'Long', 'Word'] в 'myLongWord' +} diff --git a/1-js/01-a/1-a1/1-camelcase/source/test.js b/1-js/01-a/1-a1/1-camelcase/source/test.js index bcf5e955..dadbd1a4 100644 --- a/1-js/01-a/1-a1/1-camelcase/source/test.js +++ b/1-js/01-a/1-a1/1-camelcase/source/test.js @@ -1,19 +1,18 @@ describe("camelize", function() { it("leaves an empty line as is", function() { - assert.equal(camelize(""), ""); + expect(camelize("")).toEqual(""); }); it("turns background-color into backgroundColor", function() { - assert.equal(camelize("background-color"), "backgroundColor"); + expect(camelize("background-color")).toEqual(["background", "color"]) }); it("turns list-style-image into listStyleImage", function() { - assert.equal(camelize("list-style-image"), "listStyleImage"); + expect(camelize("list-style-image")).toEqual("listStyleImage"); }); it("turns -webkit-transition into WebkitTransition", function() { - assert.equal(camelize("-webkit-transition"), "WebkitTransition"); + expect(camelize("-webkit-transition")).toEqual("WebkitTransition") }); - -}); \ No newline at end of file +}); diff --git a/1-js/02-b/1-b1/2-hoverintent/solution/hoverIntent.js b/1-js/02-b/1-b1/2-hoverintent/solution/hoverIntent.js index 44bd2745..c9b307aa 100644 --- a/1-js/02-b/1-b1/2-hoverintent/solution/hoverIntent.js +++ b/1-js/02-b/1-b1/2-hoverintent/solution/hoverIntent.js @@ -1,4 +1,4 @@ -class HoverIntent { +export default class HoverIntent { constructor({ sensitivity = 0.1, // speed less than 0.1px/ms means "hovering over an element" diff --git a/1-js/02-b/1-b1/2-hoverintent/source/hoverIntent.js b/1-js/02-b/1-b1/2-hoverintent/source/hoverIntent.js index b73c6257..9fd479a4 100644 --- a/1-js/02-b/1-b1/2-hoverintent/source/hoverIntent.js +++ b/1-js/02-b/1-b1/2-hoverintent/source/hoverIntent.js @@ -1,6 +1,6 @@ // Here's a brief sketch of the class // with things that you'll need anyway -class HoverIntent { +export default class HoverIntent { constructor({ sensitivity = 0.1, // speed less than 0.1px/ms means "hovering over an element" @@ -25,12 +25,9 @@ class HoverIntent { elem.addEventListener("mouseout", this.onMouseOut); // continue from this point - } onMouseOver(event) { - console.error(console.log); - console.log("OVER", event); /* ... */ } diff --git a/1-js/02-b/1-b1/2-hoverintent/source/index.html b/1-js/02-b/1-b1/2-hoverintent/source/index.html index c1d30b66..3ad401bb 100644 --- a/1-js/02-b/1-b1/2-hoverintent/source/index.html +++ b/1-js/02-b/1-b1/2-hoverintent/source/index.html @@ -1,5 +1,4 @@ -