java script some basic start
comment - //
multiline comment - /* kd write any number of line */
variables
var number1 = 12;
var number2 = 34;
console.log(number1+number2);
objects//
var marks = {
ravi = 26,
raju = 34,
vijay = 65
}
Booleans
var a = true;
var b = false;
.
Two types of data type in javascript
1- primitive data type: undefined, null, number,string,boolean,symbol
2- reference data type: Arrays and Object
write array :
var arr = [1,2,3,4,5]
/// check on console - console.log(arr[2]); or console.log(arr);
// operator in javascript
Athematic operator
var a = 100
var b = 10
console.log("The value of a+b is ", a+b);
// Assigment Operators
var c = b;
c += 2;
console.log(c)
//comparision operatos
var x = 10
var y = 20
console.log(x==y)
console.log(x>=y)
console.log(x<=y)
// logical operator
console.log(true && true);
console.log(false && false);
// logical or operator
console.log(true || false);
console.log(false || false);
// logical not operator
console.log(!false);
console.log(!true);
// function
function avg(a, b){
return (a + b)/2;
}
c = avg(4, 6)
c2 = avg(25, 98)
console.log(c);
console.log(c2);
// conditional
var age = 23;
if(age > 20){
console.log("your age is more than 20")
}
else{
console.log("your age is less than 20")
}
// else-if ladder
if(age < 32){
console.log("you are a kid")
}
else if(age < 32){
console.log("you are actually a kid")
}
else {
console.log("I am a kid")
}
Comments
Post a Comment