Skip to content

Commit ebf38ab

Browse files
committed
arrays, objects and for loop concept added
1 parent aaf0b7f commit ebf38ab

File tree

1 file changed

+121
-13
lines changed

1 file changed

+121
-13
lines changed

yourPlayground.js

Lines changed: 121 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -72,21 +72,129 @@ function weather() //weather fu
7272
// console.log(calFoodTotal(100,30))
7373

7474
//arrow function
75-
sumArrow=()=>
76-
{
77-
x=Number(prompt('x?'))
78-
y=Number(prompt())
79-
return x + y
80-
}
75+
// sumArrow=()=>
76+
// {
77+
// x=Number(prompt('x?'))
78+
// y=Number(prompt())
79+
// return x + y
80+
// }
8181

8282

83-
console.log(sumArrow())
84-
sumArrow=(a,b)=>a+b
83+
// console.log(sumArrow())
84+
// sumArrow=(a,b)=>a+b
8585

86-
console.log(sumArrow(5,8))
86+
// console.log(sumArrow(5,8))
8787

88-
function name(a,b)
89-
{
90-
return a+b
88+
// function name(a,b)
89+
// {
90+
// return a+b
91+
// }
92+
// console.log(name('hi',0))
93+
94+
//ARRAY
95+
96+
// array=['a','b','c','d']
97+
// console.log(array)
98+
// // console.log(array[0])
99+
// // console.log(array[2])
100+
101+
// array.push('e') //push operation
102+
// console.log(array)
103+
104+
// console.log(array.slice(0,2)) //0 is included and 2 is excluded slice operation
105+
106+
// console.log(array.indexOf('b'))
107+
// console.log(array.length)
108+
109+
110+
111+
112+
113+
114+
115+
//OBJECTS
116+
117+
118+
119+
// const person = { //person object
120+
// name: 'ishika',
121+
// rollNo: '2116173'
122+
// }
123+
124+
// console.log(person.name) //dot notation
125+
// console.log(person.rollNo)
126+
127+
// console.log(person['name']) //bracket bracket
128+
// console.log(person['rollNo'])
129+
130+
131+
// person.phnNo = '020-34456873' //object asssign
132+
133+
// console.log(person.phnNo)
134+
135+
// console.log(person)
136+
137+
138+
139+
// const person2 = {
140+
// name : 'hi',
141+
// class : 'hlo'
142+
// }
143+
144+
// console.log(person.name) //dot notation
145+
// console.log(person.class)
146+
147+
// console.log(person)
148+
// console.log(person2)
149+
150+
151+
152+
153+
// const introducer = (name ,shirt) => {
154+
155+
// const person = {
156+
// name1 : name ,
157+
// shirt1 : shirt,
158+
// assets : 100000,
159+
// liabilities : 5000,
160+
// netWorth : function(){
161+
// return this.assets-this.liabilities
162+
// }
163+
// }
164+
// console.log(`hi my name is ${person.name1} and i wear ${person.shirt1} and it's networth is ${person.netWorth()}`)
165+
// }
166+
167+
// introducer('ishika','blue')
168+
169+
170+
171+
172+
173+
//FOR LOOP
174+
175+
176+
// const fruit = ['a','b','c','d']
177+
178+
// for(i=0;i<fruit.length;i++)
179+
// console.log(i,fruit[i])
180+
181+
// for(const john of fruit) {
182+
// console.log(john)
183+
// }
184+
185+
// for(const fruit of fruit) { //WRONG PRACTICE
186+
// console.log(fruit)
187+
// }
188+
189+
190+
const no = ['1','2','3','4']
191+
sum=0
192+
193+
let result = []
194+
for(const john of no) {
195+
sum+=Number(john)
196+
result.push(sum)
91197
}
92-
console.log(name('hi',0))
198+
199+
console.log(sum)
200+
console.log(result)

0 commit comments

Comments
 (0)