Created
January 22, 2021 11:36
-
-
Save onliniak/29beea47949223624a0240ac950e5348 to your computer and use it in GitHub Desktop.
Prosty kalkulator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let obliczenia = 0; | |
| math = {} | |
| math.dodaj = 5 | |
| math.razy = 3 | |
| function oblicz(matm) { | |
| sort = Object.entries(matm).sort((k, v) => k[0].localeCompare(v[0])); | |
| for (i = 0; i < sort.length; i++) { | |
| switch (sort[i][0]) { | |
| case "dodaj": | |
| obliczenia = obliczenia + sort[i][1] | |
| break; | |
| case "razy": | |
| obliczenia = obliczenia * sort[i][1] | |
| break; | |
| } | |
| } | |
| return obliczenia | |
| } | |
| h = oblicz(math) | |
| console.log(h) # → 15 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment