SIGMA WEB DEV JAVASCRIPT CLASS NOTES:
JavaScript Variables, Data Types & Objects | Sigma Web Development Course - Tutorial #55
console.log("Shivam");
console.log("hey this is tutorial 55");
let a = 6;// data type number ...
let b = 5;// data type number ...
let c = "Harry"; // data type "string" = collection of characters ...
// console.log(a + b + 8);
// // using typeof operator
// console.log(typeof a,typeof b,typeof c);
let _a = "Shubham"; // chalega
// var 55a = "Rohan"; // nahi chalega
// const a1 = 6; redefining const is not allowed
// a1 = a1 + 2;
// its not allowed
{
let a = 66;
console.log(a);
}
console.log(a);
let x = "Harry bhai";
let y = 3.33;
let z = 22;
const p = true;
let q = undefined;
let r = null;
console.log(x,y,z,p,q,r);
console.log(typeof x,typeof y,typeof z,typeof p,typeof q,typeof r);
// console.log(typeof null); // it prints "object" but correct one is "null" // its an INTERVIEW QUESTION ...
// ?? Wait typeof "object" = null -- because in past developer made a mistake that they write "object" = null by mistake but today we cannot change because so much old code is relia on that wrong code so we cannot change it...
// object = bohat sari chije ek entity ke bare me ...
let o = {
name: "Harry",
"job code": 5600,
"is_handsome":true,
}
// console.log(o);
o.salary = "100crore";
// console.log(o);
o.salary = "500crore";
console.log(o);
// Chapter - 1 : practice set
//Q-1.create a variable of type string and try to add a number to it
var s = "string";
console.log(s);
var n = 12;
console.log(n);
var ns = n+s;
console.log(ns);
//Q-2.use type operator to find the datatype of the string in last question
var s = "string";
console.log(s);
var n = 12;
console.log(n);
var ns = n+s;
console.log(ns);
console.log(typeof ns);
//Q-3.create a constant obj in javascript can you change it to hold a number later?
const obj = {
key : "value",
}
obj.newkey = "newvalue";
console.log(obj);
//Q-4.try to add a new key to the const obj in problem 3 were you able to do it?
const obj = {
key : "value",
}
obj.newkey = 11;
console.log(obj);
//Q-5.write a js program to create a word-meaning dictionary of 5 word
const o = {
Abate : "to reduce in intensity or amount to lessen",
Benevolent : "showing kindness or goodwill; charitable",
Concur : " to agree with someone or something",
Diligent : "hardworking and careful in one work or duties",
Eloquent : "fluent or persuasive in speaking or writing",
}
// console.log(o.Abate)
JavaScript Conditionals:if,else if,else ladder|Sigma - Tutorial #56
console.log("Shivam");
let age = 0;
let grace = 1;
age += grace;
console.log(age);
console.log(age + grace);
console.log(age - grace);
console.log(age * grace);
console.log(age / grace);
console.log(age ** grace); // exponentiation operator
console.log(age % grace); // modulus operator
// if else if else Ladder ......
if (age == 18) {
console.log("You can drive");
} // if block
else if (age == 0) {
console.log("Are you Kidding?");
} else if (age == 1) {
console.log("Are you again Kidding?");
} else {
console.log("you cannot drive");
} // else block
// NODE JS "REPEL" = Read Evalute Print Loop ...
// COMMENT***
/*I
am
multiline
comment
*/
// I am Comment
a = 6;
b = 8;
c = a > b ? a - b : b - a;
/*
translates to:
if(a>b){
let c = a - b;
}
else{
let c = b - a;
}
*/
// Chapter - 2 : Practice set
// Q-1: Use logical operator to find whether the age of a person is lies between 10 and 20 ...
let age = 15; // Replace this with the desired age
if (age >= 10 && age <= 20) {
console.log("The age is between 10 and 20.");
} else {
console.log("The age is not between 10 and 20.");
}
// Q-2: Demonstrate the use of switch case statements in javascript ...
// not so much important ...
// Q-3: write a javascript program to find whether a number is divisible by 2 and 3 ...
var number = 18;
if (number % 2 === 0 && number % 3 === 0) {
console.log("The number is divisible by both 2 and 3.");
} else {
console.log("The number is not divisible by both 2 and 3.");
}
// Q-4: Write a java script program to find whether a number is divisible by either 2 or 3 ...
var number = 18;
if (number % 2 === 0 || number % 3 === 0) {
console.log("The number is divisible by both 2 and 3.");
} else {
console.log("The number is not divisible by both 2 and 3.");
}
// Q-5: Print "You can Drive" or "You cannot Drive" based on age being greater than 18 using ternary operator ...
var age = 19;
if (age >= 18) {
console.log("You can Drive");
} else {
console.log("You cannot Drive");
}
Comments
Post a Comment