javascript
javascript
the website
// // console.log("HEllo");
// console.log("Hello WOrld");
// // arrays;
// const arr = ["adsf", "asf", 2, true];
// console.log(arr);
// let a = 4;
// a = [3, 4, 5, 6];
// console.log(a);
// // functions
// function greetings() {
// console.log("Hello World");
// }
// greetings();
// // // return
// function add(a, b) {
// const c = a + b;
// return c;
// }
// const x = add(2, 3);
// console.log(x);
// console.log(adding(4, 5));
// // conditional operators
// let a = "2";
// let b = 2;
// console.log(a == b); // compares value
// console.log(a === b); // compares value and the datatype
// b = "2";
// console.log(a === b);
// //logical operator
// let person = {
// name: "Vishal",
// age: 21
// };
// //switch
// const dice = 3;
// switch (dice) {
// case 1:
// console.log("ONE");
// break;
// case 2:
// console.log("TWO");
// break;
// default:
// console.log("NOT ALLOWED");
// }
// //loops
// let amount = 4;
// while (amount > 0) {
// console.log("Printed from while loop");
// console.log("idk");
// amount--;
// }
// let am = 4;
// do {
// console.log("printed from do-while");
// console.log("idk");
// am--;
// } while (am > 0);
// for (let i = 0; i <= 4; i++) {
// console.log("Printed from for loop");
// console.log("idk");
// }
//////////////////lecture 8/////////////////////////////////////
// //string properties
// //String methods -- returns the string
// //creates object of string and jS wraps
// // creates new memory instead of changing original string
// console.log(text.length);
// const x = text.toUpperCase();
// console.log(x);
// const y = text.toLowerCase();
// console.log(y);
// const b = text.indexOf("i");
// console.log(b);
// //template literals
// // strings can be initialised in double quote and single quote
// //yet there is another powerful way (back ticks ` `)
// //Array methods
// const arr = [1, 2, 3];
// // //length
// // console.log(arr.length);
// // //.concat(arr2);
// const arr2 = [5, 6, 7, 8, 9];
// const x = arr.concat(arr2);
// console.log(x);
// // //reverse();
// // console.log(arr.reverse());
// // //.push() pop();
// // arr.push(4);
// // arr.push(4);
// // arr.push(4);
// // console.log(arr);
// // arr.pop();
// // arr.pop();
// // arr.pop();
// // console.log(arr);
// //calling by funtion
// const printarr = (a) => {
// for (let i = 0; i < a.length; i++) {
// console.log(a[i]);
// }
// };
// printarr(arr);
// //references vs values
// // primitive datatypes--> pass by value
// const number = 1;
// let number2 = number;
// number2 = 4;
// console.log(number, number2);
// // objects-->pass by references
// const obj1 = {
// a: 3,
// b: 6
// };
// //Null vs Undefined
// //Undefined-->when JS cant value a variable
// //NULL--> developers assign this value
// let number = 20 + null;
// console.log(number);
// let number2 = 20 + undefined;
// console.log(number2);
// operators
// unary operators = ! , single opearand
// binary operator = +,-,/ , two operators(a+b),a and b are operands
// ternary operator = ex:
// (condition) ? (return if true) : (return false)
// fun{
// //code block
// }
//Global scope
// variable declared can be accessed in any code
//block and outsite code block too
//Local scope
// variable dec in code block can br accessed
// within code block
// // variable lookup
// function add(a, b) {
// const Globalnum = 5;
// const res = a + b + Globalnum;
// function multiply() {
// const num = 100;
// console.log(num * res * Globalnum);
// }
// multiply();
// console.log(res);
// }
// add(3, 4);
// // Globalnum will look for the nearest declared value
// function morning(name) {
// return `Good Morning ${name}`;
// }
// function afternoon(name) {
// return `Good Afternoon ${name}`;
// }
// function greet(name, callback) {
// const myName = "Gandu";
// console.log(`${callback(name)}, My name is ${myName}`);
// }
// greet("Vishal", morning); //calling fun in fun
// greet("Vishal", afternoon); // passing as reference not as afternoon()
// remember syntax
// //forEach
// numbers.forEach((number) => {
// console.log(number);
// });
// let persons = [
// { name: "Vishal", department: "MME", age: "21", id: 1 },
// { name: "Naman", department: "MME", age: "25", id: 2 },
// { name: "OND", department: "MME", age: "24", id: 3 }
// ];
// console.log(newArr);
// //find
// // it returns the first element which match the condition
// // Math
// const pi = Math.PI;
// console.log(pi);
// //Date
// const today = new Date();
// console.log(today);
// console.log(today.getSeconds());
// console.log(today.getDay());
// console.log(today.getMonth());