Posts

Showing posts with the label function

 Create a Function to roll a dice & always display the value of the dice (1 to 6).

  function ran (){   let rand = Math.floor(Math.random() * 6) + 1 console.log(rand); } ran()

function practice()

 function hello (){   console.log("hello") } hello() // ----------------------------------------------------------------  function name (){   console.log("navjot singh") } name() // --------------------------------------------------------------------  function print (){   for(let i = 1; i<=5; i++){     console.log(i)   } } print() // ------------------------------------------------------------------------------  function practice(){   for(let i = 1; i<10; i++){     console.log(i)   } } practice() // ---------------------------------------------------------------  function isa (){   let age = 69   if(age<18){     console.log("you are not eligible")   }   else if(age>70){     console.log("your age is old")   }   else{     console.log("you are eligible")   } } isa(17) // ----------------------------------------------------------  // Ho...

Arrow function add 2 values

 let a = (a, b) => console.log(a+b) a(2, 3)

function add 2 values global and local

 let a = 5; function local(){   let b = 3   console.log(a+b) } local()

basic function add 2 + 3

 function add (a, b){   console.log(a+b) } add(2, 3) ----------------------------------------------------------------------------------------- let fun = function(){ console.log("hello) } function()