javascript-dasar-function

Run Settings
LanguageJavascript
Language Version
Run Command
function greeting(name, language) { if(language === "English") { console.log("Good Morning " + name + "!"); } else if (language === "French") { console.log("Bonjour " + name + "!"); } else { console.log("Selamat Pagi " + name + "!"); } } greeting("Harry", "French"); /* output Bonjour Harry! */
function multiply(a, b) { return a * b; } let result = multiply(10, 2) console.log(result) /* output 20 */ function greeting(name, language) { if(language === "English") { return "Good Morning " + name + "!"; } else if (language === "French") { return "Bonjour " + name + "!"; } else { return "Selamat Pagi " + name + "!"; } } let greetingMessage = greeting("Harry", "French"); console.log(greetingMessage); /* output Bonjour Harry! */
function sapaan(nama, bahasa){ if(bahasa === "indonesia"){ console.log("Selamat Pagi "+ nama); }else if(bahasa === "english"){ console.log("Good Morning "+ nama); }else if(bahasa === "french"){ console.log("Bonjour "+ nama); }else{ console.log("haii.. " +nama); } } sapaan("Aji", "indonesia"); function hitung(a,b){ return a*b; } let hasil= hitung(5,10); console.log(hasil); console.log(""); console.log(""); console.log("===Function Return==="); function ucapan(nama, bahasa){ if(bahasa === "indonesia"){ return("Selamat Pagi "+ nama); }else if(bahasa === "english"){ return("Good Morning "+ nama); }else if(bahasa === "french"){ return("Bonjour "+ nama); }else{ return("haii.. " +nama); } } let salam = ucapan("Aji", "english"); console.log(salam)
Editor Settings
Theme
Key bindings
Full width
Lines