-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotes
More file actions
132 lines (129 loc) · 3.05 KB
/
notes
File metadata and controls
132 lines (129 loc) · 3.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
// console.log("first program");
console.log("easy or tough");
let a=45;
let b=2;
//if-else
/*
if(a%2==0){
console.log(a ,"is even");
}
else{
console.log(a," is odd");
}*/
//ternary operator
// c=a>18?"adult":"not adult";
// console.log(c);
// let x=prompt("enter score ");
// if(x>=90 && x<=100){
// console.log( "Grade:A");
// }
// else if(x>=70 && x<=89){
// console.log("Grade:B");
// }
// else if(x>60 && x<=69){
// console.log("Grade:C");
// }
// else if(x>50 && x<=59){
// console.log("Grade:D");
// }
// else{
// console.log("Grade:F");
// }
//loops in js
// console.log("multiples of 2 are:");
// for(let i=1;i<=10;i++){
// console.log(2*i);
// }
//sum of 1 to n using for loop
// let sum=0;
// let n=prompt("enter the number");
// for(let i=1;i<=n;i++){
// sum=sum+i;
// }
// console.log(sum);
//print all even numbers from 0 to 100
// console.log("the even numbers from 0 to 100 are")
// for(let i=0;i<=100;i++){
// if(i%2==0){
// console.log(i);
// }
// }
// game guessing number
// let gameNumber=30;
// let guessGameNumber=prompt("guess the number:");
// while(gameNumber!=guessGameNumber){
// guessGameNumber=prompt("you entered wrong number ,guess again:");
// }
// if(gameNumber==guessGameNumber){
// console.log("you won");
// }
//practice question
// let fullName=prompt("enter your full name");
// let username="@"+fullName+fullName.length;
// console.log(username);
// //arrays
// let item=[94,97,94,92,90];
// for(let i=0;i<item.length;i++){
// item[i]=item[i]-item[i]/10;
// }
// console.log(item);
//practice question
// let companies=["microsoft","amazon","apple","netflix","google"];
// companies.shift();
// companies.push("ibm");
// companies.splice(0,1,"facebook");
// console.log(companies);
//functions
// function strings(msg){
// return msg.length;
// }
// console.log(strings("hellomynameisadilrasheed"));
//arrow functions
// const arrowstr=(msg)=>{
// return msg.length;
// }
// console.log(arrowstr("helloworld"));
// count vovewls in string
// function countvowels(str){
// let count=0;
// for(let char of str){
// if(char==='a' || char==='e' || char==='i' || char==='o' || char==='u'){
// count++;
// }
// } return count;
// }
// console.log(countvowels("adilrasheed"));
//for each loop
// let arr=[90,97,89,94,78,92];
// let newArr=arr.filter((val)=>{
// return val>=90;
// }
// )
// console.log(newArr);
//---------------
// let n=prompt("enter the number:");
// let arr=[];
// for(let i=1;i<=n;i++){
// arr[i-1]=i;
// }
// console.log(arr);
// const output=arr.reduce((pre,current)=>{
// return pre*current;
// })
// console.log(output)
//document object model
/*
//togggle button
let btn=document.querySelector("#btn");
let currentMode="light";
btn.addEventListener("click",()=>{
if(currentMode==="light"){
currentMode="dark";
document.querySelector("body").classList.add("dark");
}
else{
currentMode="light";
document.querySelector("body").classList.add("light");
}
})*/
//events in javascript