diff --git a/11-date-array/app.js b/11-date-array/app.js new file mode 100644 index 0000000..cb2e1b6 --- /dev/null +++ b/11-date-array/app.js @@ -0,0 +1,9 @@ +const date = ['10-02-2022', 'тест', '11/12/2023', '00/12/2022', '41/12/2023', '30/02/2024']; + +const validDates = date + .map(date => new Date(date)) + .filter(date => !isNaN(date)) + .map(date => date.toLocaleDateString('ru-RU')) + .sort((a, b) => a - b); + +console.log(validDates); \ No newline at end of file diff --git a/11-date-array/index.html b/11-date-array/index.html new file mode 100644 index 0000000..5143a36 --- /dev/null +++ b/11-date-array/index.html @@ -0,0 +1,12 @@ + + + + + + Document + + + + + + \ No newline at end of file diff --git a/12-luna/app.js b/12-luna/app.js new file mode 100644 index 0000000..a1f5b2d --- /dev/null +++ b/12-luna/app.js @@ -0,0 +1,27 @@ +const card = '4561-2612-1234-5464'; + +function correctCardNumber (cardNum) { + console.log(cardNum); + cardNum = cardNum + .trim() + .replaceAll('-', '') + console.log(cardNum) + + if (cardNum.length != 16) { + return false; + } + // Проверка по Алгоритму Луны + let sum = 0; + for (let i = 0; i < cardNum.length; i++) { + let numbers = Number(cardNum[i]); + if ((cardNum.length - i) % 2 === 0) { + numbers *= 2; + if (numbers >= 9) { + numbers -= 9; + } + sum += numbers; + } + } + return sum % 10 === 0; +} +console.log(correctCardNumber(card)); \ No newline at end of file diff --git a/12-luna/index.html b/12-luna/index.html new file mode 100644 index 0000000..9e911f1 --- /dev/null +++ b/12-luna/index.html @@ -0,0 +1,12 @@ + + + + + + + Document + + + + + \ No newline at end of file diff --git a/7-converter/app.js b/7-converter/app.js new file mode 100644 index 0000000..3d552b7 --- /dev/null +++ b/7-converter/app.js @@ -0,0 +1,32 @@ +function summ (amount, sourceCurrency, targetCurrency) { + switch (sourceCurrency) { + case 'RUB': switch (targetCurrency) { + case 'USD': return amount / 89.7619; + case 'EUR': return amount / 97.9126; + case 'GBP': return amount / 113.6027; + default: return null; + } + case 'USD': switch (targetCurrency) { + case 'RUB': return amount * 89.7619; + case 'EUR': return amount * 0.9168; + case 'GBP': return amount * 0.7901; + default: return null; + } + case 'EUR': switch (targetCurrency) { + case 'RUB': return amount * 97.9126; + case 'USD': return amount * 1.0908; + case 'GBP': return amount * 0.8619; + default: return null; + } + case 'GBP': switch (targetCurrency) { + case 'RUB': return amount * 113.6027; + case 'USD': return amount * 1.2656; + case 'EUR': return amount * 1.1602; + default: return null; + } + default: + return null; + } +}; + +console.log(summ(1000, 'RUB', 'USD')); \ No newline at end of file diff --git a/7-converter/index.html b/7-converter/index.html new file mode 100644 index 0000000..5143a36 --- /dev/null +++ b/7-converter/index.html @@ -0,0 +1,12 @@ + + + + + + Document + + + + + + \ No newline at end of file diff --git a/8-crypto/app.js b/8-crypto/app.js new file mode 100644 index 0000000..060fbe7 --- /dev/null +++ b/8-crypto/app.js @@ -0,0 +1,22 @@ +function crypto(password) { + let cryptoPass = password.split(['']); + cryptoPass.reverse(); + return cryptoPass; +}; +console.log(crypto('password')); + + +function check() { + let encryptedPass = crypto('password'); + encryptedPass.reverse(); + let truePass = encryptedPass.join(''); + + switch (truePass) { + case 'password': + console.log('Пароль верный!'); + break; + default: + console.log('Пароль неверный!'); + }; +}; +console.log(check()); \ No newline at end of file diff --git a/8-crypto/index.html b/8-crypto/index.html new file mode 100644 index 0000000..5143a36 --- /dev/null +++ b/8-crypto/index.html @@ -0,0 +1,12 @@ + + + + + + Document + + + + + + \ No newline at end of file diff --git a/9-sort-loops/app.js b/9-sort-loops/app.js new file mode 100644 index 0000000..bdf9aea --- /dev/null +++ b/9-sort-loops/app.js @@ -0,0 +1,15 @@ +const arr = [1, 40, -50, -20, -10, 5, 0, 100]; + +function arrSort() { + for (let j = arr.length - 1; j > 0; j--) { + for (let i = 0; i < j; i++) { + if (arr[i] > arr[i + 1]) { + let temp = arr[i]; + arr[i] = arr[i + 1]; + arr[i + 1] = temp; + }; + }; + }; + return arr; +} +console.log(arrSort(arr)); \ No newline at end of file diff --git a/9-sort-loops/index.html b/9-sort-loops/index.html new file mode 100644 index 0000000..5143a36 --- /dev/null +++ b/9-sort-loops/index.html @@ -0,0 +1,12 @@ + + + + + + Document + + + + + + \ No newline at end of file