diff --git a/Exercises/1-let.js b/Exercises/1-let.js index d705443..011cc55 100644 --- a/Exercises/1-let.js +++ b/Exercises/1-let.js @@ -1,5 +1,5 @@ 'use strict'; -let name = undefined; +let name = 'Michil'; module.exports = { name }; diff --git a/Exercises/2-const.js b/Exercises/2-const.js index 5512738..0041b5a 100644 --- a/Exercises/2-const.js +++ b/Exercises/2-const.js @@ -1,5 +1,5 @@ 'use strict'; -const year = undefined; +const year = 2000; module.exports = { year }; diff --git a/Exercises/3-hello.js b/Exercises/3-hello.js index a597391..17b496b 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..b78da6f 100644 --- a/Exercises/4-range.js +++ b/Exercises/4-range.js @@ -1,5 +1,10 @@ 'use strict'; -const range = null; - +const range = (start, end) => { + const massiv = []; + for (start; start <= end; start++) { + massiv.push(start); + } + return massiv; +}; module.exports = { range }; diff --git a/Exercises/5-range-odd.js b/Exercises/5-range-odd.js index 54bb5b4..db88eb4 100644 --- a/Exercises/5-range-odd.js +++ b/Exercises/5-range-odd.js @@ -1,5 +1,11 @@ 'use strict'; -const rangeOdd = null; +const rangeOdd = (start, end) => { + const massiv = []; + for (start; start <= end; start++) { + if (start % 2 !== 0) massiv.push(start); + } + return massiv; +}; module.exports = { rangeOdd }; diff --git a/Exercises/6-calculate.js b/Exercises/6-calculate.js index dfecf6b..8be7dc0 100644 --- a/Exercises/6-calculate.js +++ b/Exercises/6-calculate.js @@ -1,11 +1,19 @@ '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 = null; +const calculate = () => { + const massiv = []; + for (let i = 0; i <= 9; i++) { + const znach1 = cube(i); + const znach2 = square(i); + massiv.push(average(znach1, znach2)); + } + return massiv; +}; module.exports = { square, cube, average, calculate }; diff --git a/Exercises/7-objects.js b/Exercises/7-objects.js index 0920026..ccc85e3 100644 --- a/Exercises/7-objects.js +++ b/Exercises/7-objects.js @@ -1,5 +1,17 @@ 'use strict'; -const fn = null; +const fn = () => { + const kek = { name: 'mich' }; + let lol = { + name: 'lyalya', + }; + kek.name = 'dada'; + lol.name = 'xoxoox'; + console.log(kek.name); + console.log(lol.name); + lol = { dada: 'asdsadsad' }; +}; + +fn(); module.exports = { fn }; diff --git a/Exercises/8-create.js b/Exercises/8-create.js index ac27ddd..52d3503 100644 --- a/Exercises/8-create.js +++ b/Exercises/8-create.js @@ -1,5 +1,8 @@ 'use strict'; -const createUser = null; +const createUser = (name, city) => { + const user = { name, city }; + return user; +}; module.exports = { createUser }; diff --git a/Exercises/9-array.js b/Exercises/9-array.js index 466c69a..33f9ab4 100644 --- a/Exercises/9-array.js +++ b/Exercises/9-array.js @@ -1,7 +1,13 @@ 'use strict'; -const phonebook = null; +const phonebook = [{ name: 'Michil', phone: '+79143053718' }, + { name: 'Lyulya', phone: '+79969156656' }]; -const findPhoneByName = null; +const findPhoneByName = (name) => { + for (const nam of phonebook) { + if (nam.name === name) return nam.phone; + } +}; +findPhoneByName('Lyulya'); module.exports = { phonebook, findPhoneByName }; diff --git a/Exercises/a-hash.js b/Exercises/a-hash.js index 466c69a..2f85bf2 100644 --- a/Exercises/a-hash.js +++ b/Exercises/a-hash.js @@ -1,7 +1,11 @@ 'use strict'; -const phonebook = null; +const phonebook = { + mich: '+79143053718', + lyalya: '+79969156656', +}; + +const findPhoneByName = (name) => phonebook(name); -const findPhoneByName = null; module.exports = { phonebook, findPhoneByName };