Skip to content

Commit cc6ca18

Browse files
jamesjose03jamesgeorge007
authored andcommitted
feat: rearrangement of tasks (#43)
1 parent 63d02bf commit cc6ca18

File tree

4 files changed

+37
-37
lines changed

4 files changed

+37
-37
lines changed

src/workspace/js/solutions/task12.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
function add(a, b) {
2-
console.log(a + b);
1+
let no = [45, 23, 767, 921];
2+
3+
for (let i = 0; i < no.length; i++) {
4+
if (no[i] > 23) console.log(no[i]);
35
}
4-
add(1, 2);
5-
add(10, 15);
6-
add(100, 400);

src/workspace/js/solutions/task13.js

+20-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
1-
let no = [45, 23, 767, 921];
2-
3-
for (let i = 0; i < no.length; i++) {
4-
if (no[i] > 23) console.log(no[i]);
5-
}
1+
let a = ['ABC', 'GHI', 'DEF', 'JKL'];
2+
let b = [1, 2, 3];
3+
a.pop();
4+
console.log(a);
5+
a.push('PQR');
6+
console.log(a);
7+
a.shift();
8+
console.log(a);
9+
a.splice(1, 2, 'WER', 'ERT');
10+
console.log(a);
11+
a = a.concat(b);
12+
console.log(a);
13+
a.sort();
14+
console.log(a);
15+
a.reverse();
16+
console.log(a);
17+
let c = b.map(element => {
18+
return 2 * element;
19+
});
20+
console.log(c);

src/workspace/js/solutions/task14.js

+6-20
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,6 @@
1-
let a = ['ABC', 'GHI', 'DEF', 'JKL'];
2-
let b = [1, 2, 3];
3-
a.pop();
4-
console.log(a);
5-
a.push('PQR');
6-
console.log(a);
7-
a.shift();
8-
console.log(a);
9-
a.splice(1, 2, 'WER', 'ERT');
10-
console.log(a);
11-
a = a.concat(b);
12-
console.log(a);
13-
a.sort();
14-
console.log(a);
15-
a.reverse();
16-
console.log(a);
17-
let c = b.map(element => {
18-
return 2 * element;
19-
});
20-
console.log(c);
1+
function add(a, b) {
2+
console.log(a + b);
3+
}
4+
add(1, 2);
5+
add(10, 15);
6+
add(100, 400);

src/workspace/js/tasks.json

+7-7
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,21 @@
5252
{
5353
"task": "Awesome! Let's now move on to break and continue statements. \n break statement is used to break out of the loop when required. It stops the iteration when used in loops. \n continue statments are used to skip the current iteration. \n The difference between these statements is that in the case of break statement, the iteration stops and breaks out of loop, whereas, in the case of continue, the iteration is skipped but the loop continues to execute. \n Here's your task: \n Task 11:- \n Print numbers from 1 to 15. Skip the iteration if the number is a multiple of 3 and break out of the loop when it reaches 13.",
5454
"op": "/solutions/task11.js"
55-
},
56-
57-
{
58-
"task": "Keep up the good work! The next topic we will cover is functions. Functions are sections of code that execute other code and make it reusable. \nIn ES6 there are 2 main ways to declare a function, the function keyword and arrow functions.\n Syntax: function name(params) {\n code\n} \nTask 12: Declare a function using the respective keyword that when given 2 numbers will add them together, then print out the result. The number pairs you need to test are 1+2, 10+15, 100+400",
59-
"op": "/solutions/task12.js"
6055
},
6156

6257
{
6358
"task": "Fantastic! Now let's move on to arrays. \n Arrays are used to store multiple values in a single variable. It can be thought of as a collection of things of the same type. Like, a collection of roll numbers. \n Arrays are declared using []. Eg: let rollno = [1,2,3] \n Here's your task: \n Task 13 \n Store the values 45,23,767,921 into an array and print the values of the array which are greater than 23. Use arrayname.length to get the length of the array.",
64-
"op": "/solutions/task13.js"
59+
"op": "/solutions/task12.js"
6560
},
6661

6762
{
6863
"task": "Now, let's move on to array methods. \n Arrays have a variety of methods which is of a lot of help in day-to-day tasks. \n Let's get to know them: 1. pop() - Used to remove the last item from the array. \n 2. push() - Used to insert an element to the end of the array. \n 3. shift() - Used to remove the first item from the array. \n 4. splice() - Used to replace the old elements with new elements to the array. \n 5. concat() - to merge two arrays. \n 6. sort() - to sort an array \n 7. reverse() - to reverse an array. \n 8. map() - creates a new array by performing a function on each element. \n Phew! That's a lot of methods. Let's now work with each of them with the help of this task. \n Task 14 \n Create an array with the values ABC, GHI, DEF and JKL. Do the following. 1. Remove JKL from the array.\n 2. Insert PQR into the array. \n 3. Remove ABC from the array. \n 4. Replace the values DEF and PQR with WER and ERT \n 5. Create another array with values 1,2,3 and merge it with the current array. \n 6. Sort the array. \n 7. Reverse the order of elements of the array. \n 8. Create another array with elements of the second array with elements doubled and print the newly created array. \n Print the output in every case.",
69-
"op":"/solutions/task14.js"
64+
"op":"/solutions/task13.js"
65+
},
66+
67+
{
68+
"task": "Keep up the good work! The next topic we will cover is functions. Functions are sections of code that execute other code and make it reusable. \nIn ES6 there are 2 main ways to declare a function, the function keyword and arrow functions.\n Syntax: function name(params) {\n code\n} \nTask 12: Declare a function using the respective keyword that when given 2 numbers will add them together, then print out the result. The number pairs you need to test are 1+2, 10+15, 100+400",
69+
"op": "/solutions/task14.js"
7070
},
7171

7272
{

0 commit comments

Comments
 (0)