Posts

Showing posts from May, 2024

How to print last no of var

   let name = "navjot sinhj" typeof name name[4] name [name.lenght-1]

How to check the length of var

 let name = "navjot sinhj" typeof name name.length

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()

Program to check if the number is positive if else

// Program to check if the number is positive let a = 1 if(a < 0){   console.log(` ${a} is negative`) }   else if (a >= 0){     console.log('this is positive no')   } else{ console.log("no this number is not found") }

check if score is fifty or greater if else

 // check if score is fifty or greater let score = 30 if (score >= 50) {   console.log(`yes ${score} is greater then 50`) } else{   console.log("you are smaler then 50") }