Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

js function

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!
Comment

js function

function name(parameter1, parameter2, parameter3) {
// what the function does
}
Comment

js function

function MyFunction() {
	/* Function Here */
}
Comment

js function

function myfunction(p1,p2){
    return p1+p2 // للجمع بين القيمتان
}
console.log(myfunction(10,20)) // النتيجة 30
Comment

define function js

var myFunction = function(p1, p2, p3){
	return "foo";
};
Comment

define function JavaScript

//! 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
});
Comment

Function syntax Js

function funkyFunction(music, isWhiteBoy) {
  if (isWhiteBoy) {
    console.log('Play: ' +  music);
  }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: slice() javascript 
Javascript :: query mongodb - nodejs 
Javascript :: trim function 
Javascript :: JavaScript Debug usage Example 
Javascript :: prototype example 
Javascript :: javascript expression interpolation 
Javascript :: javascript test throw error 
Javascript :: passport js npm 
Javascript :: indexof 
Javascript :: bind method in js 
Javascript :: get week number of month from date moment 
Javascript :: get body 
Javascript :: how to change background color in css and or js react 
Javascript :: js for loop 
Javascript :: convert number into string 
Javascript :: line graph view click event 
Javascript :: django send and receive image data to react 
Javascript :: filter based on input typing react 
Javascript :: import css files maven resources with jsf 
Javascript :: You are getting a `numbers` array. Return the sum of **negative** numbers only. //condition to check for negative 
Javascript :: when uncheck remove value from div javascript 
Javascript :: angular error ng0303 ngForIn 
Javascript :: jquery to javascript converter online 
Javascript :: express react docker container example 
Javascript :: two dimensional array object in javascript 
Javascript :: node silent print to themral 
Javascript :: renderer.setElementStyle 
Javascript :: js increment safety value html 
Javascript :: let scores = [80, 90, 70]; for (const score of scores) { console.log(score); } 
Javascript :: var fn = () = { return new Promise(r = r(5)) } 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =