Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
207 changes: 207 additions & 0 deletions Day1/Day1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
// Javascript use let,const and Var Keyword to store the data//

// What is a Variable -: A variable is a container for a value, like a number we
// might use in a sum, or a string that we might use as part of a sentence.


// Try to prefer Let over var. Var was declared back and let is a new keyword //
// Var supports Hoisting but let don't//

// Secondly, when you use var, you can declare the same variable as many times as you like, but with let you can't

let x = 6 // Assigning the variables//
console.log(x);

const y = 10;
// We Can't override this Value//

//------------------------------------------------------------------------------------------------------------

// DataTypes in Javascript
// a)String b) Number c)BigInt d)Boolean e)Undefined f)Null g)Symbol h)Object

let car1name = "Volvo";
let car2name = "Chevrolet";

// String Datatype//

let i = 20.00;
let number2 = 50;

// Number Dataype;
//Stored in 64 Bit//
let xx = BigInt("123456789012345678901234567890");

//Primitive Data Type
//A primitive type has a fixed size in memory. For example, a number occupies eight bytes of memory, and a boolean value can be represented with only one bit.
//The number type is the largest of the primitive types.
// If each JavaScript variable reserves eight bytes of memory, the variable can directly hold any primitive value

//Reference types are another matter, however. Objects, for example, can be of any length -- they do not have a fixed size.
//The same is true of arrays: an array can have any number of elements. Similarly, a function can contain any amount of JavaScript code. Since these types do not have a fixed size, their values cannot be stored directly in the eight bytes of memory associated with each variable.
//Instead, the variable stores a reference to the value.
//Typically, this reference is some form of pointer or memory address.
//It is not the data value itself, but it tells the variable where to look to find the value.


//Undefined and Null

//Undefined-: When a variable is innitialise but no value assigned then it directlu takes undefined as its value
//Accessing it's Value will give you undefined as it's out put//
//It's primitive Value//

//Example

let xu;
console.log(xu);

function hey(){
// No return statement so the default value is Undefined
}

//NULL

//Deliberate assignment that represent the absense of any object Value
//It is also a primitive Value

//Var -: Global and Local Scope,
//Local Scope -: while local scope is for variables declared inside functions.

var num = 40;
function f(){
var square = number*number; // Local Scope -: Declared Inside Functions//
console.log(square); // We can access it inside the Function
}

f();
//---------------------------------------------------------------------------------------

//Another Function to understand the Var and their Scope

function ff(){
var number = 40;
var square = number*number;
console.log(square);
}

ff();

console.log(number) // Reference error as number have local scope -: Reference Error
//Variable with var keyword can be redclared and reassigned
//if any value is not assigned to the var variable the the default value it contains is undefined












//-------------------------------------------------------------------------------------------------------
//Arithmetic Operators -: +,-,*,/,%,**,++,--
//Additional Operators
let numbr1 = 1;
let num2 = 4;
console.log(numbr1+num2);

//subtraction Operator

let yu = 10;
let uy = 50;
console.log(uy-yu);

//Multiplying operator

let initial1 = 0;
let initial2 = 0;
console.log(0*0);

//Division Operator

let div1 = 10;
let div2 = 2;
console.log(div1/div2);

//Remainder Operator -: We will use modulus here

let gh = 10;
let hg = 2;
console.log(gh%hg);

// ** operator is called exponential and ** == Math.pow()//

//Assignment Operator

//a) =
//b) +=
//c) -=
//d) *=
//e) /=
//f) %=
//g) **=


// Shift Assignment Operator
//a) <<=
//b) >>=
//c) >>>=


//Bitwise Assignment Operator
//a) &=
//b) ^=
//c) |=

//Logical Assignment Operator
//a) &&=
//b) ||=
//c) ??=


//Example

let answer = 10; // Simple Assignment Operator

let answer2 = 0; //Addition Assignment Operator
answer2+=10;

let answer3 = 10; //Subtraction Assignment Operator
answer3-=5;

let answer4 = 19; // Multiplication assignment Operator//
answer4*=12;

let answer5 = 10; // Exponentian Assignment Operator//
answer5**=5;

let answer6 = 14; // Division Assignment Operator
answer4/=7

let answer7 = 19; // Modulo Assignment Operator//
answer7%=8;

let answer8 = 100; // Left Shift Assignment Operator
answer8<<=5;

let answer9 = 90; // Right Shift Assignment Operator//
answer9>>=8;


//------------------------------------------------------------------------------

//Comparison Operator

//a) == equal to
//b) === equal value and equal Type
//c) !=not equal
//d) !== not equal or not equal Type
//e) > greater than
//f) < less than
//g) >= greater than equal to
//h) <= less than equal to


179 changes: 179 additions & 0 deletions Day1/Practiceday1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
const prompt = require('prompt-sync')();
var x; // Genral way to define a Variable in Javascript//
var y;

var x = 10; // Defining some value to variable called x;

// To print or to get an output we use Console.log

console.log(x); // printing the value of x//

// Let,use and Const are the keywords.

let var1 = 10;
var var2 = 20;
const var3 = 30;

//--------------------------------------------------------------------------------


//Primitive Data Type

//Number Data Type

let number1 = 10;
let number2 = 20;
let number3 = 4.5 // Floating Point Number.

//String

let string1 = "Ankit";
let string2 = 'Saini';
console.log(string1,"This is a String");
console.log(string2,'Printing a string');

//String using Backticks//

let string3 = `Hey there ${string1} how are you`;
console.log(string3);

// Boolean -: return 1 or 0 based on the condiiton

// const user1= prompt("Enter the Number");

// if(user1 >= 10){
// console.log("True");
// return true;
// }

// else{
// console.log("False");
// return false;
// }

//null - It basically means it is empty whereas undefined means it is not assigned//
//Big Int//
//Big int is a built in object in Javascript that provides a way to represent whole number greater than 253-1//


let bigbin = BigInt("0b1010101001010101001111111111111111");
// console.log(bigbin);

//-------------------------------------------------------------------------

//Object is a Reference data type

// JavaScript objects are fundamental data structures used to store collections of data.
// They consist of key-value pairs and can be created using curly braces {} or the new keyword

//-----------------------------------------------------------------------------------------
//Understanding Var keyword -:
var variable1 = 10;
function f(){
var variable2 = 95;
console.log(variable2,variable1);
}
f();
// console.log(variable2);
var variable1 = 20;
console.log(yu); // Hoisting concept//
var yu = 20;
//----------------------------------------------------------------------------------------------
//Let Keyword -: Introduced in 2016 and an improved Version of Var keyword//
//Let Keyword has the Block Scope//
// Re declaration is Allowed//

let let1 = 10; //Global Scope//
function g(){ // Function Scope//
let2 = 11;
console.log(let1); // Can be accessed because let1 has Global Scope//
console.log(let2);
}
g();


let func1 = 10;
function test2(){
let temp1 = 20;
if(temp1>=20){
let temp2 = 90;
}
console.log(temp2); // Reference error can't be accessed//
}


console.log(temp3);
let temp3 = 20; // Hoisting error//


// Const keyword -: Mainly used for those variables that will be constant throughout the process//
// Block Scope and const keyword can't be declared and reassign//

const a = 10;
function f(){
a = 9; // Can't be assigned//
console.log(a);
}
f();


// Assignment Operators
//assign value

let assign1 = 10; // Here = operator is used to assign the values//
assign1+=10// Addition assignment Operator//
assign1-=10;//Subtraction Assignment Operator//
assign1*=10;//Multiplication Assignment Operator//
assign1/=24;//Division Assignment Operator//
assign1**=2;//Exponentian Assignment Operator It's similar to Math.pow(a,b)//


// Shift Assignment Operator//
let variable6 = 24;
variable6>>=2;// Right Shift Assignment Operator//
variable6<<=2;//Left Shift Assignment Operator//

//Bitwise Assignment Operator//

variable6&=2;//And Operation//
variable6 |=4; // Or Operation
variable6^=4;//Bitwise Operation//
//----------------------------------------------------------------------------------------------------------

//Comparison Operators

let variablee = 10;
let variablee2 = 20;

if(variablee == variablee2){ // It will only evaluate value not type as it is not considering strictly equality
console.log("equal");
}
else{
console.log("Not equal");
}


if(variablee === variablee2){ // Checking the type also//
console.log("");
}
else{
console.log("")
}

if(variablee > variablee2){
console.log("Variablee is greater than variablee2");
}

else if(variablee2 > variablee){
console.log("Variablee2 is greater than variablee");
}


//-----------------------------------------------------------------------------------

//Logical Operators
//&&, ||, !
// && -: This operator name is AND and it specify that if both of the
//value are correct then the statement will be executed
//|| -: Determines that if any of the condition is true then the statement will executed
//
Loading