From 4e867b7134b8384fca3ecb8fce972668ed3fe455 Mon Sep 17 00:00:00 2001 From: GrimdvlWork Date: Fri, 27 Oct 2023 13:42:13 +0300 Subject: [PATCH 1/3] lesson_5 create new folder + 2 files and miniCalculator --- .../PokemonProject/4-basics/basics.js | 30 +++++++++++++++++++ .../PokemonProject/4-basics/index.html | 11 +++++++ 2 files changed, 41 insertions(+) create mode 100644 homeworks/artem.sokur_Grimdvl/PokemonProject/4-basics/basics.js create mode 100644 homeworks/artem.sokur_Grimdvl/PokemonProject/4-basics/index.html diff --git a/homeworks/artem.sokur_Grimdvl/PokemonProject/4-basics/basics.js b/homeworks/artem.sokur_Grimdvl/PokemonProject/4-basics/basics.js new file mode 100644 index 00000000..c8756f87 --- /dev/null +++ b/homeworks/artem.sokur_Grimdvl/PokemonProject/4-basics/basics.js @@ -0,0 +1,30 @@ +const firstString = +prompt('Enter the first number:', '').trim(); +const sign = prompt('Enter mathematic sign (+, -, *, /, %, **):', '').trim(); +const secondString = +prompt('Enter the second number:', '').trim(); + +const firstNumber = +firstString; +const secondNumber = +secondString; + +function calculator() { + let result; + + if (sign === '+') { + result = firstNumber + secondNumber; + } else if (sign === '-') { + result = firstNumber - secondNumber; + } else if (sign === '*') { + result = firstNumber * secondNumber; + } else if (sign === '/') { + result = firstNumber / secondNumber; + } else if (sign === '%') { + result = firstNumber % secondNumber; + } else if (sign === '**') { + result = firstNumber ** secondNumber; + } else { + result = 'Ups! Something went wrong...'; + } + return result; +} +const equal = calculator(); +alert(`Your result: ${Number.isNaN(equal) || equal === undefined || equal === '' ? 'Ups! Something went wrong...' : equal}`); +window.location.reload(); diff --git a/homeworks/artem.sokur_Grimdvl/PokemonProject/4-basics/index.html b/homeworks/artem.sokur_Grimdvl/PokemonProject/4-basics/index.html new file mode 100644 index 00000000..fe71363a --- /dev/null +++ b/homeworks/artem.sokur_Grimdvl/PokemonProject/4-basics/index.html @@ -0,0 +1,11 @@ + + + + + + Calculator + + + + + \ No newline at end of file From 58bdcc7c8ed574cf32f519604fd5afeb52e120db Mon Sep 17 00:00:00 2001 From: GrimdvlWork Date: Fri, 27 Oct 2023 13:47:51 +0300 Subject: [PATCH 2/3] lesson_5 delete 2 useless variables --- .../PokemonProject/4-basics/basics.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/homeworks/artem.sokur_Grimdvl/PokemonProject/4-basics/basics.js b/homeworks/artem.sokur_Grimdvl/PokemonProject/4-basics/basics.js index c8756f87..c84214b0 100644 --- a/homeworks/artem.sokur_Grimdvl/PokemonProject/4-basics/basics.js +++ b/homeworks/artem.sokur_Grimdvl/PokemonProject/4-basics/basics.js @@ -1,9 +1,6 @@ -const firstString = +prompt('Enter the first number:', '').trim(); +const firstNumber = +prompt('Enter the first number:', '').trim(); const sign = prompt('Enter mathematic sign (+, -, *, /, %, **):', '').trim(); -const secondString = +prompt('Enter the second number:', '').trim(); - -const firstNumber = +firstString; -const secondNumber = +secondString; +const secondNumber = +prompt('Enter the second number:', '').trim(); function calculator() { let result; @@ -23,8 +20,10 @@ function calculator() { } else { result = 'Ups! Something went wrong...'; } + return result; } const equal = calculator(); + alert(`Your result: ${Number.isNaN(equal) || equal === undefined || equal === '' ? 'Ups! Something went wrong...' : equal}`); window.location.reload(); From 2d2358a613174b0408fa023f0ed60cf9e9e128b5 Mon Sep 17 00:00:00 2001 From: GrimdvlWork Date: Fri, 27 Oct 2023 14:00:31 +0300 Subject: [PATCH 3/3] lesson_5 moving folder --- .../artem.sokur_Grimdvl/{PokemonProject => }/4-basics/basics.js | 0 .../artem.sokur_Grimdvl/{PokemonProject => }/4-basics/index.html | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename homeworks/artem.sokur_Grimdvl/{PokemonProject => }/4-basics/basics.js (100%) rename homeworks/artem.sokur_Grimdvl/{PokemonProject => }/4-basics/index.html (100%) diff --git a/homeworks/artem.sokur_Grimdvl/PokemonProject/4-basics/basics.js b/homeworks/artem.sokur_Grimdvl/4-basics/basics.js similarity index 100% rename from homeworks/artem.sokur_Grimdvl/PokemonProject/4-basics/basics.js rename to homeworks/artem.sokur_Grimdvl/4-basics/basics.js diff --git a/homeworks/artem.sokur_Grimdvl/PokemonProject/4-basics/index.html b/homeworks/artem.sokur_Grimdvl/4-basics/index.html similarity index 100% rename from homeworks/artem.sokur_Grimdvl/PokemonProject/4-basics/index.html rename to homeworks/artem.sokur_Grimdvl/4-basics/index.html