You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: javascript_for_web.js
+98Lines changed: 98 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -531,4 +531,102 @@ function checkBalance(amount){
531
531
bankBalance=console.log(checkBalance(200));//500
532
532
533
533
// UPNEXT: STAND IN LINE;
534
+
//This works similar to Queues and stacks in computer sciece;
535
+
//Boolean Values: True/fals , on/off 1/0
536
+
//Conditional statements with if logic (used to make decisions)
537
+
//comparison with equality operator (uses equal sign to do comaprison between operators);
538
+
//comaparison with the strict equality operator; (===) has no type of conversion unlke == where we can compare ints n strings by converting them to strings
539
+
//practise comparing different values === & == in one function . conversioncacn happens using .typeOf Function.
540
+
functionnextInLine(arr,item){
541
+
arr.push(item);
542
+
returnarr.shift();
543
+
}
544
+
vartestArr=[1,2,3,4,5];
545
+
console.log("Before: "+JSON.stringify(testArr));
546
+
console.log(nextInLine(testArr,8));
547
+
console.log("After: "+JSON.stringify(testArr));
548
+
549
+
550
+
//boolean
551
+
functionwelcomeToBooleans(){
552
+
returntrue;
553
+
}
554
+
console.log(welcomeToBooleans());// Reurns true
555
+
556
+
//if statements
557
+
//Ex1
558
+
functiontest(myCondition){
559
+
if(myCondition){
560
+
return"It was true";
561
+
}
562
+
return"It was false";
563
+
}
564
+
test(true);// returns "It was true"
565
+
test(false);// returns "It was false"
566
+
567
+
// Ex2
568
+
functionourTrueOrFalse(isItTrue){
569
+
if(isItTrue){
570
+
return"Yes, it's true";
571
+
}
572
+
return"No, it's false";
573
+
}
574
+
console.log(ourTrueOrFalse(true));
575
+
576
+
//ex3
577
+
functiontrueOrFalse(wasThatTrue){
578
+
if(wasThatTrue){
579
+
return"Yes, that was true";
580
+
}
581
+
return"No, that was false";
582
+
}
583
+
584
+
console.log(trueOrFalse(false));
585
+
586
+
//comparison
587
+
//Ex1
588
+
functionequalityTest(myVal){
589
+
if(myVal==10){
590
+
return"Equal";
591
+
}
592
+
return"Not Equal";
593
+
}
594
+
// Ex2
595
+
functiontestEqual(val){
596
+
if(val==12){// Change this line
597
+
return"Equal";
598
+
}
599
+
return"Not Equal";
600
+
}
601
+
console.log(testEqual(10));
602
+
//Ex3
603
+
functioncomapreTwoVal(nums){
604
+
if(nums==50){
605
+
return"Equal to 50";
606
+
}
607
+
return"Not equal to 500";
608
+
}
609
+
console.log(comapreTwoVal(50));
610
+
611
+
612
+
//Strict comparison:
613
+
614
+
functiontestStrict(val){
615
+
if(val===7){
616
+
return"Equal";
617
+
}
618
+
return"Not Equal";
619
+
}
620
+
console.log(testStrict(7));//Equal
621
+
622
+
623
+
functionstrictTestNotSameType(num){
624
+
if(num===10){
625
+
return"strictly equal";
626
+
}
627
+
return"Not strictly Eqaul";
628
+
}
629
+
console.log(strictTestNotSameType("10"));// Not eqal
0 commit comments