diff --git a/.eslintrc.json b/.eslintrc.json index c945f41..e7cec2a 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -18,7 +18,7 @@ ], "linebreak-style": [ "error", - "unix" + "windows" ], "quotes": [ "error", @@ -267,10 +267,12 @@ }, "overrides": [ { - "files": ["1-let.js"], + "files": [ + "1-let.js" + ], "rules": { "prefer-const": "off" } } ] -} +} \ No newline at end of file diff --git a/Exercises/1-let.js b/Exercises/1-let.js index d705443..d22e831 100644 --- a/Exercises/1-let.js +++ b/Exercises/1-let.js @@ -1,5 +1,5 @@ 'use strict'; -let name = undefined; +let name = 'Alex'; module.exports = { name }; diff --git a/Exercises/2-const.js b/Exercises/2-const.js index 5512738..219cf61 100644 --- a/Exercises/2-const.js +++ b/Exercises/2-const.js @@ -1,5 +1,5 @@ 'use strict'; -const year = undefined; +const year = 1992; module.exports = { year }; diff --git a/Exercises/3-hello.js b/Exercises/3-hello.js index a597391..458783c 100644 --- a/Exercises/3-hello.js +++ b/Exercises/3-hello.js @@ -1,5 +1,5 @@ 'use strict'; -const hello = null; +const hello = name => console.log(`Добро пожаловать ${name}`); module.exports = { hello }; diff --git a/Exercises/4-range.js b/Exercises/4-range.js index 31bd852..6cf4035 100644 --- a/Exercises/4-range.js +++ b/Exercises/4-range.js @@ -1,5 +1,12 @@ 'use strict'; -const range = null; +const range = (start, end) => { + const rangeOfNum = []; + for (let i = start; i <= end; i++) { + rangeOfNum.push(i); + } + + return rangeOfNum; +}; module.exports = { range }; diff --git a/Exercises/5-range-odd.js b/Exercises/5-range-odd.js index 54bb5b4..64e5945 100644 --- a/Exercises/5-range-odd.js +++ b/Exercises/5-range-odd.js @@ -1,5 +1,16 @@ 'use strict'; -const rangeOdd = null; +const rangeOdd = (start, end) => { + const rangeOddNum = []; + for (let i = start; i <= end; i++) { + const oddNum = Math.abs(i) % 2 === 1; + if (oddNum) { + rangeOddNum.push(i); + } + } + + return rangeOddNum; +}; + module.exports = { rangeOdd }; diff --git a/Exercises/6-calculate.js b/Exercises/6-calculate.js index dfecf6b..5e589a9 100644 --- a/Exercises/6-calculate.js +++ b/Exercises/6-calculate.js @@ -1,11 +1,20 @@ 'use strict'; -const square = null; +const square = x => x * x; -const cube = null; +const cube = x => x ** 3; -const average = null; +const average = (a, b) => (a + b) / 2; + +const calculate = () => { + const result = []; + for (let i = 0; i <= 9; i++) { + const aveResult = average(cube(i), square(i)); + result.push(aveResult); + } + + return result; +}; -const calculate = null; module.exports = { square, cube, average, calculate }; diff --git a/Exercises/7-objects.js b/Exercises/7-objects.js index 0920026..ffd1d6d 100644 --- a/Exercises/7-objects.js +++ b/Exercises/7-objects.js @@ -1,5 +1,14 @@ 'use strict'; -const fn = null; +const fn = () => { + const obj1 = { name: 'Саша' }; + // eslint-disable-next-line prefer-const + let obj2 = { name: 'Ксюша' }; + + obj1.name = 'Александр'; + obj2.name = 'Ксения'; + + obj2 = { name: 'Ксю' }; +}; module.exports = { fn }; diff --git a/Exercises/8-create.js b/Exercises/8-create.js index ac27ddd..f400582 100644 --- a/Exercises/8-create.js +++ b/Exercises/8-create.js @@ -1,5 +1,5 @@ 'use strict'; -const createUser = null; +const createUser = (name, city) => ({ name, city }); module.exports = { createUser }; diff --git a/Exercises/9-array.js b/Exercises/9-array.js index 466c69a..ad24600 100644 --- a/Exercises/9-array.js +++ b/Exercises/9-array.js @@ -1,7 +1,14 @@ 'use strict'; -const phonebook = null; +const phonebook = [ + { name: 'Marcus Aurelius', phone: '+380445554433' }, + { name: 'Alex White', phone: '+380445554434' } +]; -const findPhoneByName = null; +const findPhoneByName = n => { + for (const { name, phone } of phonebook) { + if (name === n) return phone; + } +}; module.exports = { phonebook, findPhoneByName }; diff --git a/Exercises/a-hash.js b/Exercises/a-hash.js index 466c69a..e5d5b50 100644 --- a/Exercises/a-hash.js +++ b/Exercises/a-hash.js @@ -1,7 +1,10 @@ 'use strict'; -const phonebook = null; +const phonebook = { + 'Marcus Aurelius': '+380445554433', + 'Alex White': '+380445554434' +}; -const findPhoneByName = null; +const findPhoneByName = name => (phonebook[name]); module.exports = { phonebook, findPhoneByName };