Created
May 30, 2025 22:11
-
-
Save smart-onion/237941b9232d4cef3e2bd024f0ffed9d to your computer and use it in GitHub Desktop.
JS10
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
| // task 1 | |
| function onError(error){ | |
| console.log(error) | |
| } | |
| function onSuccess(result){ | |
| console.log(result) | |
| } | |
| function devider(a,b,onSuccess,onError){ | |
| if (b === 0) { | |
| onError("Zero division error") | |
| } | |
| else{ | |
| onSuccess(`Success: ${a} / ${b} = ${a/b}`) | |
| } | |
| } | |
| devider(10,2,onSuccess,onError) | |
| // task 2 | |
| function logElement(elem){ | |
| console.log(elem); | |
| return elem; | |
| } | |
| function squareElement(elem) {return elem * elem} | |
| function processArray(arr, action) {return arr.map(a => action(a))} | |
| console.log(processArray([1,2,3,4], logElement)); | |
| console.log(processArray([1,2,3,4], squareElement)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment