Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c1cc796

Browse files
committed
[Veer] Added : Practice Problems on JavaScript
1 parent 2425849 commit c1cc796

File tree

9 files changed

+231
-0
lines changed

9 files changed

+231
-0
lines changed

‎ArrowFunctions.js‎

Whitespace-only changes.

‎MApReduceFilter/NeedToStudy‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Default Parameters in ES6.
2+
Template Literals in ES6.
3+
Multi-line Strings in ES6.
4+
Destructuring Assignment in ES6.
5+
Enhanced Object Literals in ES6.
6+
Arrow Functions in ES6.
7+
Promises in ES6.
8+
Block-Scoped Constructs Let and Const.

‎MApReduceFilter/mapreducefilter.js‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// let students = [
2+
// {name : "Veer", age : 22},
3+
// {name : "Priya", age : 21}
4+
// ]
5+
6+
// let personsBelow21 = students.filter((ages) => ages.age <= 21)
7+
// console.log(personsBelow21)
8+
9+
10+
// let marks = [99,95,85,90,68,87];
11+
// let compressTo50 = marks.filter((a) => a>88)
12+
// .map((a) => a+2)
13+
// console.log(compressTo50)
14+
15+
///////////////////////////////////////////////////////////////////////
16+
17+
// let findTotal = marks.reduce((a,b) => a+b)
18+
// console.log(findTotal)
19+
// function sum ()
20+
// let findSum = marks.reduce()
21+
22+
// let totalMarksInOrder = marks.slice(0)
23+
// .sort()
24+
// console.log(totalMarksInOrder)
25+
26+
//Object Array
27+
28+
const objects = [{ x: 1 }, { x: 2 }, { x: 3 }];
29+
30+
const sum2 = objects.reduce(
31+
(acc, curr) => acc + curr,
32+
);
33+
console.log(sum2)
34+
35+
//array.reduce(function(total, currentValue, currentIndex, arr), initialValue)

‎calculation.js‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const prompt = require("prompt-sync")();
2+
3+
class calculator{
4+
5+
addition = (a,b) => a+b
6+
subtraction = (a,b) => a-b;
7+
multiply = (a,b) => a*b;
8+
division = (a,b) => a/b;
9+
}
10+
let calc = new calculator()
11+
console.log(calc.addition(10,20))
12+
console.log(calc.subtraction(10,5))
13+
console.log(calc.multiply(10,5))
14+

‎classJS.js‎

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/**
2+
* Can you create Employee Payroll Data
3+
with id, name and
4+
salary
5+
Create all methods and functions also
6+
getter setter and constructor should also be there
7+
*/
8+
class Employee{
9+
id;
10+
name;
11+
salary;
12+
constructor (id,name,salary){
13+
this.id = id
14+
this.name = name
15+
this.salary = salary
16+
}
17+
set setId( id){
18+
id = this.id
19+
}
20+
get getId(){
21+
return this.id
22+
}
23+
set setName(name){
24+
name = this.name
25+
}
26+
get getName(){
27+
return this.name
28+
}
29+
set setSalary(salary){
30+
salary = this.salary
31+
}
32+
get getSalary(){
33+
return this.salary
34+
}
35+
}
36+
let worker1 = new Employee(1,"Veer",10000)
37+
let worker2 = new Employee(2,"Priya",15000)
38+
console.log(worker1)
39+
console.log(worker2)
40+
41+
worker1.setName = "Viru"
42+
console.log(worker1)
43+
44+

‎jsarrays‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
var array = [1,2,3,4,5]
2+
var starray = ["veer","priya","hitesh","swayam","mehul"]
3+
console.log(array.length)
4+
console.log(starray.length)
5+
const array3 = [2,4,5,6,7,8]
6+
console.log(array3.length)
7+
8+
console.log(array.reverse())
9+
10+
function sorting(a,b){
11+
return b-a;
12+
}
13+
console.log(array.sort(sorting)) // Sorting
14+
15+
let ar1 = [1,3,5,7,9]
16+
let ar2 = [2,4,6,8,0]
17+
18+
console.log(ar1.join("-"));
19+
20+
console.log(ar1.concat(ar2)) //Contactinating 2 integer arrays
21+
22+
let starr2 = ["Sushmitha","Abhishek","Amol"]
23+
24+
console.log(starray.concat(starr2)) //Concating 2 strings arrays
25+
26+
console.log(ar1.concat(starr2)) //Concating int with string arrays
27+
28+
let res1 = starray.concat(starr2);
29+
let res2 = (ar1.concat(ar2));
30+
console.log(typeof(res1))
31+
console.log(typeof(res2))
32+
let rse3 = ar1.join("-")
33+
console.log(typeof(rse3))
34+
35+
let arrn1 = [11,12,13,14,15,16,17,18,19,20]
36+
//arr.splice(start, deleteCount, item1, ..., itemN)
37+
console.log(arrn1.slice(5,9));
38+
console.log(arrn1.splice(5,10))

‎jspractice.js‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
let students = ["Veer","Priya","Hitesh","Prakash"]
2+
//Stack Opearations
3+
students.push("Sushmitha","Amol","Mehul")
4+
students.pop()
5+
console.log(students)
6+
7+
//forEach
8+
students.forEach(scaning)
9+
function scaning(students){
10+
11+
}
12+
let leftpeople = ["Shreyas","Dipali"]
13+
let rfp175 = students.concat(leftpeople)
14+
console.log(rfp175)
15+
16+
let newBAtch = rfp175.slice(0)
17+
console.log(newBAtch)
18+
19+
let oldfriends = ["Siva","Anusha"]
20+
let otherbatch = students.concat(oldfriends)
21+
console.log(otherbatch)
22+
23+
let checkstudents = otherbatch.join("-")
24+
console.log(checkstudents)
25+
26+
let students1 = otherbatch.splice(2,1,"Himanshu")
27+
console.log(otherbatch)
28+
29+
30+
31+
console.table(otherbatch)

‎mapDataStructure.js‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/**
2+
* 'a', 1
3+
'b',22
4+
'c',32
5+
'd',65
6+
const map1 = new Map();
7+
8+
create map DataStructure
9+
*/
10+
11+
const map1 = new Map();
12+
map1.set('a',1)
13+
map1.set('b',22)
14+
map1.set('c',32)
15+
map1.set('d',65)
16+
17+
let value = map1.get('d')
18+
console.log(value)
19+
map1.set('a',14)
20+
console.log(map1)
21+
22+
console.log("size is :",map1.size)
23+
24+
// map1.delete('a')
25+
// map1.delete('b')
26+
// map1.delete('c')
27+
// console.log("Deleted 3 values",map1)
28+
29+
// map1.forEach(element => {
30+
// console.log(element)
31+
// element = element+1
32+
// });
33+
34+
for(let element of map1.values()){
35+
element = element+1
36+
console.log(element)
37+
38+
}
39+
console.table(map1)

‎methodspractice.js‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
let a,b,result
2+
function addition (a,b){
3+
return a+b
4+
}
5+
result = addition(5,9)
6+
console.log(result);
7+
function multiplication(a,b){
8+
return a*b
9+
}
10+
result = multiplication(2,6)
11+
console.log(result);
12+
13+
a=10
14+
var a1
15+
console.log(a1);
16+
b1 =15
17+
let b1
18+
console.log(b1)
19+
20+
21+
22+

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /