function myfunction() {
console.log("function");
};
myfunction() //Should say "function" in the console.
function calculate(x, y, op) {
var answer;
if ( op = "add" ) {
answer = x + y;
};
else if ( op = "sub" ) {
answer = x - y;
};
else if ( op = "multi" ) {
answer = x * y;
};
else if ( op = "divide" ) {
answer = x / y;
};
else {
answer = "Error";
};
return answer;
};
console.log(calculate(15, 3, "divide")); //Should say 5 in console.
//I hope I helped!
function name(parameter1, parameter2, parameter3) {
// what the function does
}
function MyFunction() {
/* Function Here */
}
function myfunction(p1,p2){
return p1+p2 // للجمع بين القيمتان
}
console.log(myfunction(10,20)) // النتيجة 30
var myFunction = function(p1, p2, p3){
return "foo";
};
//! Button Click Event
//! regular function
document.querySelector("button").addEventListener('click', handlClick);
function handlClick() {
alert("I got clicked!")//just to show it works
//what to do when click detected
}
//!anonymous function
document.querySelector("button").addEventListener('click',function handlClick() {
alert("I got clicked!")//just to show it works
//what to do when click detected
});
function funkyFunction(music, isWhiteBoy) {
if (isWhiteBoy) {
console.log('Play: ' + music);
}
}