Created
June 3, 2021 15:25
-
-
Save ahhzaky/304b43f18ea6147727c83a68ed210e9e to your computer and use it in GitHub Desktop.
Test js function
This file contains 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
/** | |
* TODO: | |
* 1. Buatlah fungsi bernama minimal dengan ketentuan berikut: | |
* - Menerima dua buah argumen number, a dan b. | |
* - Mengembalikan nilai terkecil antara a atau b. | |
* - Bila nilai keduanya sama, maka kembalikan dengan nilai a | |
* | |
* contoh: | |
* minimal(1, 4) // 1 | |
* minimal(3, 2) // 2 | |
* minimal(3, 3) // 3 | |
* | |
* 2. Buatlah fungsi bernama power dengan ketentuan berikut: | |
* - Menerima dua buah argumen number, a dan b. | |
* - Mengembalikan nilai dari hasil perkalian a * a sebanyak b (fungsi kuadrat). | |
* | |
* contoh: | |
* power(7, 3) // 343 | |
* power(3, 3) // 27 | |
* power(4, 0.5) // 2 | |
*/ | |
// TODO | |
//1 | |
const minimal = (a,b) =>{ | |
if(a<b){ | |
return a; | |
}else if(a==b){ | |
return a; | |
}else{ | |
return b; | |
} | |
} | |
//2 ** | |
const power = (a,b) => a**b; | |
minimal(5,2) | |
power(7, 3) // 343 | |
power(3, 3) // 27 | |
power(4, 0.5) // 2 | |
module.exports = { minimal, power }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment