From 95fc32cfce7332825d1f80908b0ad04a270f33b3 Mon Sep 17 00:00:00 2001 From: James Kaviyil Jose Date: Sun, 17 Mar 2019 21:49:47 +0530 Subject: [PATCH 01/19] Add initial tasks --- lib/workspace/js/solutions/task2.js | 2 ++ lib/workspace/js/solutions/task3.js | 2 ++ src/workspace/js/tasks.json | 12 +++++++++++- 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 lib/workspace/js/solutions/task2.js create mode 100644 lib/workspace/js/solutions/task3.js diff --git a/lib/workspace/js/solutions/task2.js b/lib/workspace/js/solutions/task2.js new file mode 100644 index 0000000..ed08af0 --- /dev/null +++ b/lib/workspace/js/solutions/task2.js @@ -0,0 +1,2 @@ +var str = 18; +console.log(str); \ No newline at end of file diff --git a/lib/workspace/js/solutions/task3.js b/lib/workspace/js/solutions/task3.js new file mode 100644 index 0000000..f831d8c --- /dev/null +++ b/lib/workspace/js/solutions/task3.js @@ -0,0 +1,2 @@ +var str = 'JS is cool!'; +console.log(str); \ No newline at end of file diff --git a/src/workspace/js/tasks.json b/src/workspace/js/tasks.json index c16c6eb..028750c 100644 --- a/src/workspace/js/tasks.json +++ b/src/workspace/js/tasks.json @@ -1,6 +1,16 @@ [ { - "task": "Hey there folks, welcome to the world of programming\n Task 1:-\n Print Hello World to the console", + "task": "Hey there folks, you have chosen JS Path! \n Here's your first task! All the best...\n Task 1:-\n Print Hello World to the console", "op": "/solutions/task1.js" + }, + + { + "task": "Great! Now's let's move on to variables. Variables are used to store data values \n Task 2:-\n Declare a variable to store the value 18 and print the value.", + "op": "/solutions/task2.js" + }, + + { + "task": "Let's move on to strings. Strings represent a set of characters written within quotes. \n Task 3:-\n Declare a variable to store the value 'JS is cool!' and print it.", + "op": "/solutions/task3.js" } ] From a77ee9f706591d2e86718223686d4cc57afa67b1 Mon Sep 17 00:00:00 2001 From: James Kaviyil Jose Date: Sun, 17 Mar 2019 23:02:15 +0530 Subject: [PATCH 02/19] Added Task 4 & Task 5(JS) :construction: --- lib/workspace/js/solutions/task4.js | 9 +++++++++ lib/workspace/js/solutions/task5.js | 8 ++++++++ src/workspace/js/tasks.json | 9 +++++++++ 3 files changed, 26 insertions(+) create mode 100644 lib/workspace/js/solutions/task4.js create mode 100644 lib/workspace/js/solutions/task5.js diff --git a/lib/workspace/js/solutions/task4.js b/lib/workspace/js/solutions/task4.js new file mode 100644 index 0000000..40406a2 --- /dev/null +++ b/lib/workspace/js/solutions/task4.js @@ -0,0 +1,9 @@ +var str = ' Hey, this is Task 4 of JS Path! '; +console.log(str.length); +console.log(str.indexOf('Task')); +console.log(str.slice(24,26)); +var str1 = str.replace('JS','Python') +console.log(str1); +str1 = str1.concat("!"); +console.log(str1); +console.log(str1.trim()); \ No newline at end of file diff --git a/lib/workspace/js/solutions/task5.js b/lib/workspace/js/solutions/task5.js new file mode 100644 index 0000000..baff10d --- /dev/null +++ b/lib/workspace/js/solutions/task5.js @@ -0,0 +1,8 @@ +var a = 25; +var b = 33; +console.log(a+b); +console.log(a-b); +console.log(a*b); +console.log(a/b); +console.log(a%b); +console.log(a**2); \ No newline at end of file diff --git a/src/workspace/js/tasks.json b/src/workspace/js/tasks.json index 028750c..95b33ae 100644 --- a/src/workspace/js/tasks.json +++ b/src/workspace/js/tasks.json @@ -12,5 +12,14 @@ { "task": "Let's move on to strings. Strings represent a set of characters written within quotes. \n Task 3:-\n Declare a variable to store the value 'JS is cool!' and print it.", "op": "/solutions/task3.js" + }, + + { + "task": "Keep it up! Let's move on to String methods. There are a variety of methods for string manipulation in JS. Some of them are: \n 1. length - To find the length of the string. \n 2. indexOf() - Returns the first occurence of a specified text in a string. \n 3. slice() - extracts a part of a string and returns the extracted part. \n 4. replace() - replaces a specified value with another value in a string. \n 5. concat() - to join two or more strings. \n 6. trim() - removes the white space from both sides of the string. \n Task 4:-\n Obtain the following output for the string ' Hey, this is Task 4 of JS Path! ' \n Output: \n Length of the string \n Display the index of first occurence of 'Task' \n Slice the string for displaying 'JS' \n Replace JS with Python \n Concatenate '!' to the end of the string. \n Remove the whitespaces from the beginning and end of the string.", + "op": "/solutions/task4.js" + }, + { + "task": "Impressive! Let's move on to the next topic: Operators. \n There are a variety of operators. Let's move on to Arithmetic Operators: +,-,*,/,%, **. \n Here's your task:\n Task 5:- \n Take 25 & 33 as your operands and print their sum, difference, product, quotient, remainder, 25^2.", + "op": "/solutions/task5.js" } ] From 503895b229cf1021ddbff301cff3f088ffb6dd0d Mon Sep 17 00:00:00 2001 From: James Kaviyil Jose Date: Sun, 17 Mar 2019 23:37:55 +0530 Subject: [PATCH 03/19] Added Task 6-8(JS) :construction: --- lib/workspace/js/solutions/task6.js | 9 +++++++++ lib/workspace/js/solutions/task7.js | 6 ++++++ lib/workspace/js/solutions/task8.js | 6 ++++++ src/workspace/js/tasks.json | 19 ++++++++++++++++++- 4 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 lib/workspace/js/solutions/task6.js create mode 100644 lib/workspace/js/solutions/task7.js create mode 100644 lib/workspace/js/solutions/task8.js diff --git a/lib/workspace/js/solutions/task6.js b/lib/workspace/js/solutions/task6.js new file mode 100644 index 0000000..170b07a --- /dev/null +++ b/lib/workspace/js/solutions/task6.js @@ -0,0 +1,9 @@ +var a = 44; +var b = 29; +console.log(a==b); +console.log(a===b); +console.log(a!=b); +console.log(a>b); +console.log(a=b); +console.log(a<=b); diff --git a/lib/workspace/js/solutions/task7.js b/lib/workspace/js/solutions/task7.js new file mode 100644 index 0000000..9b4e956 --- /dev/null +++ b/lib/workspace/js/solutions/task7.js @@ -0,0 +1,6 @@ +var a = 34; +var b = 23; +var c = 1; +console.log((a>b)&& (ac)); +console.log(!(b, <, >=, <=. Here's your task:\n Task 6:-\n Use 44 & 29 as your operands. Compare them using the Comparison operators in the same order and print the value which they return.", + "op": "/solutions/task6.js" + }, + + { + "task": "Now, let's move on to Logical Operators. They too return true or false according to the value of their operands. They are : \n && - returns true if both operands are true \n || - returns true if any of the operands are true \n ! - negates whatever the statement inside is. \n Here's your task: \n Task 7:- \n Use 34,23,1 as your operands. Check whether\n 1. 34>23 and 34<1 \n 2. 34<23 or 34>1 \n 3. not 23<34", + "op":"/solutions/task7.js" + }, + + { + "task": "Great! Let's move on to Loops now. Loops are used to repeat the same code without writing it over and over again. \n Let's start with for loop. Syntax: \n for (initialization; condition; update)\n{// code block to be executed} \n Here's your task: \n Task 8:- \n Print the multiples of 4 from 1 to 12 using for loop.", + "op": "/solutions/task8.js" + }, + ] From c680a7891c304db8a4835005d315ee4386798f05 Mon Sep 17 00:00:00 2001 From: James Kaviyil Jose Date: Sun, 24 Mar 2019 22:29:13 +0530 Subject: [PATCH 04/19] Task 9-10 added(JS) :construction: --- lib/workspace/js/solutions/task10.js | 12 ++++++++++++ lib/workspace/js/solutions/task9.js | 12 ++++++++++++ src/workspace/js/tasks.json | 10 ++++++++++ 3 files changed, 34 insertions(+) create mode 100644 lib/workspace/js/solutions/task10.js create mode 100644 lib/workspace/js/solutions/task9.js diff --git a/lib/workspace/js/solutions/task10.js b/lib/workspace/js/solutions/task10.js new file mode 100644 index 0000000..c2a084e --- /dev/null +++ b/lib/workspace/js/solutions/task10.js @@ -0,0 +1,12 @@ +var s = 1; +do{ + if(s%2 == 0) + { + console.log(s + ' is even.'); + } + else + { + console.log(s + ' is odd.'); + } + s++; +}while(s<=20); \ No newline at end of file diff --git a/lib/workspace/js/solutions/task9.js b/lib/workspace/js/solutions/task9.js new file mode 100644 index 0000000..f633b06 --- /dev/null +++ b/lib/workspace/js/solutions/task9.js @@ -0,0 +1,12 @@ +var x = 1; +while(x<=50) +{ + if(x%5 == 0) + { + console.log('Buzz'); + } + else{ + console.log(x); + } + x++; +} \ No newline at end of file diff --git a/src/workspace/js/tasks.json b/src/workspace/js/tasks.json index 342475e..03c7903 100644 --- a/src/workspace/js/tasks.json +++ b/src/workspace/js/tasks.json @@ -38,5 +38,15 @@ "task": "Great! Let's move on to Loops now. Loops are used to repeat the same code without writing it over and over again. \n Let's start with for loop. Syntax: \n for (initialization; condition; update)\n{// code block to be executed} \n Here's your task: \n Task 8:- \n Print the multiples of 4 from 1 to 12 using for loop.", "op": "/solutions/task8.js" }, + + { + "task": "Let's move on to another loop, the while loop, along with the if-else blocks. while loop is also an entry controlled loop, i.e, it checks the condition first before it starts executing. If-else blocks are used to compare the values and execute according to the conditions given. \n Syntax: \n while(condition) \n {block of statements; update statement;} \n Here's your task: \n Task 9:- \n Print the numbers from 1 to 50. Print Buzz if the number is a multiple of 5.", + "op": "/solutions/task9.js" + }, + + { + "task": "Great work! Let's move on to another loop, the do while loop. Unlike other loops, this one is an exit controlled loop, i.e, it executes at least once. It checks the condition only at the exit. \n Syntax: do{\n loop block\n}(while(condition)); \n Here's your task: \nTask 10:-\n Iterate through the numbers 1 to 20 and print whether the number is odd or even. \n Here's the sample output: \n 1 is odd. \n2 is even. ....\n20 is even.", + "op": "/solutions/task10.js" + } ] From fac95f0f36d1036dd3222cc920a12c5e6ca16ba7 Mon Sep 17 00:00:00 2001 From: James Kaviyil Jose Date: Sun, 24 Mar 2019 22:51:24 +0530 Subject: [PATCH 05/19] Task 11 added(JS) :construction: --- lib/workspace/js/solutions/task11.js | 18 ++++++++++++++++++ src/workspace/js/tasks.json | 4 ++++ 2 files changed, 22 insertions(+) create mode 100644 lib/workspace/js/solutions/task11.js diff --git a/lib/workspace/js/solutions/task11.js b/lib/workspace/js/solutions/task11.js new file mode 100644 index 0000000..3daaa87 --- /dev/null +++ b/lib/workspace/js/solutions/task11.js @@ -0,0 +1,18 @@ +var i = 1; +while(i<=15) +{ + if(i%3 === 0) + { + i++; + continue; + } + else if(i === 13) + { + break; + } + else + { + console.log(i); + } + i++; +} \ No newline at end of file diff --git a/src/workspace/js/tasks.json b/src/workspace/js/tasks.json index 03c7903..133e40e 100644 --- a/src/workspace/js/tasks.json +++ b/src/workspace/js/tasks.json @@ -47,6 +47,10 @@ { "task": "Great work! Let's move on to another loop, the do while loop. Unlike other loops, this one is an exit controlled loop, i.e, it executes at least once. It checks the condition only at the exit. \n Syntax: do{\n loop block\n}(while(condition)); \n Here's your task: \nTask 10:-\n Iterate through the numbers 1 to 20 and print whether the number is odd or even. \n Here's the sample output: \n 1 is odd. \n2 is even. ....\n20 is even.", "op": "/solutions/task10.js" + }, + + { + "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." } ] From ba04dc3bece21f876007e2b36db68253a923401a Mon Sep 17 00:00:00 2001 From: Simon Smale Date: Sat, 5 Oct 2019 10:50:59 +0100 Subject: [PATCH 06/19] Fix(Task 2): replaces ver with const Const should be used for unchanged variables --- lib/workspace/js/solutions/task2.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/workspace/js/solutions/task2.js b/lib/workspace/js/solutions/task2.js index ed08af0..b1e75e4 100644 --- a/lib/workspace/js/solutions/task2.js +++ b/lib/workspace/js/solutions/task2.js @@ -1,2 +1,2 @@ -var str = 18; -console.log(str); \ No newline at end of file +const str = 18; +console.log(str); From e6a44162f47acffb680ef1ead65cc1200b57c46d Mon Sep 17 00:00:00 2001 From: Simon Smale Date: Sat, 5 Oct 2019 10:52:31 +0100 Subject: [PATCH 07/19] Fix(Task 3): replaces var with const const should be used for variables that do not change --- lib/workspace/js/solutions/task3.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/workspace/js/solutions/task3.js b/lib/workspace/js/solutions/task3.js index f831d8c..882c03e 100644 --- a/lib/workspace/js/solutions/task3.js +++ b/lib/workspace/js/solutions/task3.js @@ -1,2 +1,2 @@ -var str = 'JS is cool!'; +const str = 'JS is cool!'; console.log(str); \ No newline at end of file From d72c54386c882fb5c7da7ff4603991b4705aab97 Mon Sep 17 00:00:00 2001 From: Simon Smale Date: Sat, 5 Oct 2019 10:54:07 +0100 Subject: [PATCH 08/19] Fix(Task 4): uses let and const let should be used for vaiables that change and const for those that doesn't --- lib/workspace/js/solutions/task4.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/workspace/js/solutions/task4.js b/lib/workspace/js/solutions/task4.js index 40406a2..0be807d 100644 --- a/lib/workspace/js/solutions/task4.js +++ b/lib/workspace/js/solutions/task4.js @@ -1,8 +1,8 @@ -var str = ' Hey, this is Task 4 of JS Path! '; +const str = ' Hey, this is Task 4 of JS Path! '; console.log(str.length); console.log(str.indexOf('Task')); console.log(str.slice(24,26)); -var str1 = str.replace('JS','Python') +let str1 = str.replace('JS','Python') console.log(str1); str1 = str1.concat("!"); console.log(str1); From ef6cd580b45dff49f46b3c34d542d676bb118cdf Mon Sep 17 00:00:00 2001 From: Simon Smale Date: Sat, 5 Oct 2019 10:54:57 +0100 Subject: [PATCH 09/19] Fix(Task 5): replaces var with const --- lib/workspace/js/solutions/task5.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/workspace/js/solutions/task5.js b/lib/workspace/js/solutions/task5.js index baff10d..6f25698 100644 --- a/lib/workspace/js/solutions/task5.js +++ b/lib/workspace/js/solutions/task5.js @@ -1,5 +1,5 @@ -var a = 25; -var b = 33; +const a = 25; +const b = 33; console.log(a+b); console.log(a-b); console.log(a*b); From 2a12e037fac6cda490d79d4fd6137aff991a9626 Mon Sep 17 00:00:00 2001 From: Simon Smale Date: Sat, 5 Oct 2019 10:55:36 +0100 Subject: [PATCH 10/19] Fix(Task 6): replaces var with const --- lib/workspace/js/solutions/task6.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/workspace/js/solutions/task6.js b/lib/workspace/js/solutions/task6.js index 170b07a..40cb42b 100644 --- a/lib/workspace/js/solutions/task6.js +++ b/lib/workspace/js/solutions/task6.js @@ -1,5 +1,5 @@ -var a = 44; -var b = 29; +const a = 44; +const b = 29; console.log(a==b); console.log(a===b); console.log(a!=b); From b19d3ad3fe6b4a2d766f62dfc56105838d8e0fbc Mon Sep 17 00:00:00 2001 From: Simon Smale Date: Sat, 5 Oct 2019 10:56:16 +0100 Subject: [PATCH 11/19] Fix(Taks 7): replaces var with const --- lib/workspace/js/solutions/task7.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/workspace/js/solutions/task7.js b/lib/workspace/js/solutions/task7.js index 9b4e956..bc10025 100644 --- a/lib/workspace/js/solutions/task7.js +++ b/lib/workspace/js/solutions/task7.js @@ -1,6 +1,6 @@ -var a = 34; -var b = 23; -var c = 1; +const a = 34; +const b = 23; +const c = 1; console.log((a>b)&& (ac)); console.log(!(b Date: Sat, 5 Oct 2019 11:03:23 +0100 Subject: [PATCH 12/19] Fix(Task 8): updates the syntax to ES6 - the variable changes so it can be let - the variable can be declared in the for loop - === is prefered over == unless checking for falsy/truthy values - if should have {} for improved readability --- lib/workspace/js/solutions/task8.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/workspace/js/solutions/task8.js b/lib/workspace/js/solutions/task8.js index 748837e..fc6d9c8 100644 --- a/lib/workspace/js/solutions/task8.js +++ b/lib/workspace/js/solutions/task8.js @@ -1,6 +1,5 @@ -var i = 1; -for(i = 1; i<=12; i++) -{ - if(i%4 == 0) +for(let i = 1; i<=12; i++) { + if(i%4 === 0) { console.log(i); + } } \ No newline at end of file From 6f4a66a8f0df70534ca4fa1290be4363d7446faa Mon Sep 17 00:00:00 2001 From: Simon Smale Date: Sat, 5 Oct 2019 11:05:38 +0100 Subject: [PATCH 13/19] Fix(Task 9): fixes the syntax for ES6 - uses let not var - matches the brackets accross the functions --- lib/workspace/js/solutions/task9.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/workspace/js/solutions/task9.js b/lib/workspace/js/solutions/task9.js index f633b06..3a0de6b 100644 --- a/lib/workspace/js/solutions/task9.js +++ b/lib/workspace/js/solutions/task9.js @@ -1,11 +1,8 @@ -var x = 1; -while(x<=50) -{ - if(x%5 == 0) - { +let x = 1; +while(x<=50) { + if(x%5 === 0) { console.log('Buzz'); - } - else{ + } else { console.log(x); } x++; From 7e7d359bfc8c6bb31ca1461b8acbde556a506730 Mon Sep 17 00:00:00 2001 From: Simon Smale Date: Sat, 5 Oct 2019 11:14:02 +0100 Subject: [PATCH 14/19] Fix(Task 10): uses let not var - also matches the formatting to the other functions --- lib/workspace/js/solutions/task10.js | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/lib/workspace/js/solutions/task10.js b/lib/workspace/js/solutions/task10.js index c2a084e..05d7f6d 100644 --- a/lib/workspace/js/solutions/task10.js +++ b/lib/workspace/js/solutions/task10.js @@ -1,12 +1,9 @@ -var s = 1; -do{ - if(s%2 == 0) - { - console.log(s + ' is even.'); - } - else - { - console.log(s + ' is odd.'); - } - s++; -}while(s<=20); \ No newline at end of file +let s = 1; +do { + if (s % 2 === 0) { + console.log(s + ' is even.'); + } else { + console.log(s + ' is odd.'); + } + s++; +} while (s <= 20); From 65482477df1154e32e23aa7cee0735bee1cc0699 Mon Sep 17 00:00:00 2001 From: Simon Smale Date: Sat, 5 Oct 2019 11:18:29 +0100 Subject: [PATCH 15/19] Fix(Task 11): uses let not var and fixes formatting --- lib/workspace/js/solutions/task11.js | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/lib/workspace/js/solutions/task11.js b/lib/workspace/js/solutions/task11.js index 3daaa87..24d6194 100644 --- a/lib/workspace/js/solutions/task11.js +++ b/lib/workspace/js/solutions/task11.js @@ -1,18 +1,12 @@ -var i = 1; -while(i<=15) -{ - if(i%3 === 0) - { - i++; - continue; - } - else if(i === 13) - { - break; - } - else - { - console.log(i); - } +let i = 1; +while (i <= 15) { + if (i % 3 === 0) { i++; -} \ No newline at end of file + continue; + } else if (i === 13) { + break; + } else { + console.log(i); + } + i++; +} From c4fa4dd8e852260cb06fc4f2440cdaf7acb3c905 Mon Sep 17 00:00:00 2001 From: Simon Smale Date: Sat, 5 Oct 2019 11:18:57 +0100 Subject: [PATCH 16/19] Chore(linting): fixes formatting --- lib/workspace/js/solutions/task3.js | 2 +- lib/workspace/js/solutions/task4.js | 8 ++++---- lib/workspace/js/solutions/task5.js | 12 ++++++------ lib/workspace/js/solutions/task6.js | 18 +++++++++++------- lib/workspace/js/solutions/task7.js | 6 +++--- lib/workspace/js/solutions/task8.js | 10 +++++----- lib/workspace/js/solutions/task9.js | 16 ++++++++-------- 7 files changed, 38 insertions(+), 34 deletions(-) diff --git a/lib/workspace/js/solutions/task3.js b/lib/workspace/js/solutions/task3.js index 882c03e..b038b53 100644 --- a/lib/workspace/js/solutions/task3.js +++ b/lib/workspace/js/solutions/task3.js @@ -1,2 +1,2 @@ const str = 'JS is cool!'; -console.log(str); \ No newline at end of file +console.log(str); diff --git a/lib/workspace/js/solutions/task4.js b/lib/workspace/js/solutions/task4.js index 0be807d..07bc302 100644 --- a/lib/workspace/js/solutions/task4.js +++ b/lib/workspace/js/solutions/task4.js @@ -1,9 +1,9 @@ const str = ' Hey, this is Task 4 of JS Path! '; console.log(str.length); console.log(str.indexOf('Task')); -console.log(str.slice(24,26)); -let str1 = str.replace('JS','Python') +console.log(str.slice(24, 26)); +let str1 = str.replace('JS', 'Python'); console.log(str1); -str1 = str1.concat("!"); +str1 = str1.concat('!'); console.log(str1); -console.log(str1.trim()); \ No newline at end of file +console.log(str1.trim()); diff --git a/lib/workspace/js/solutions/task5.js b/lib/workspace/js/solutions/task5.js index 6f25698..88f2ed6 100644 --- a/lib/workspace/js/solutions/task5.js +++ b/lib/workspace/js/solutions/task5.js @@ -1,8 +1,8 @@ const a = 25; const b = 33; -console.log(a+b); -console.log(a-b); -console.log(a*b); -console.log(a/b); -console.log(a%b); -console.log(a**2); \ No newline at end of file +console.log(a + b); +console.log(a - b); +console.log(a * b); +console.log(a / b); +console.log(a % b); +console.log(a ** 2); diff --git a/lib/workspace/js/solutions/task6.js b/lib/workspace/js/solutions/task6.js index 40cb42b..82f3a84 100644 --- a/lib/workspace/js/solutions/task6.js +++ b/lib/workspace/js/solutions/task6.js @@ -1,9 +1,13 @@ const a = 44; const b = 29; -console.log(a==b); -console.log(a===b); -console.log(a!=b); -console.log(a>b); -console.log(a=b); -console.log(a<=b); +// This is part of the excersise +// eslint-disable-next-line eqeqeq +console.log(a == b); +console.log(a === b); +// This is part of the excersise +// eslint-disable-next-line eqeqeq +console.log(a != b); +console.log(a > b); +console.log(a < b); +console.log(a >= b); +console.log(a <= b); diff --git a/lib/workspace/js/solutions/task7.js b/lib/workspace/js/solutions/task7.js index bc10025..e339e54 100644 --- a/lib/workspace/js/solutions/task7.js +++ b/lib/workspace/js/solutions/task7.js @@ -1,6 +1,6 @@ const a = 34; const b = 23; const c = 1; -console.log((a>b)&& (ac)); -console.log(!(b b && a < c); +console.log(a < b || a > c); +console.log(!(b < a)); diff --git a/lib/workspace/js/solutions/task8.js b/lib/workspace/js/solutions/task8.js index fc6d9c8..91b4ffe 100644 --- a/lib/workspace/js/solutions/task8.js +++ b/lib/workspace/js/solutions/task8.js @@ -1,5 +1,5 @@ -for(let i = 1; i<=12; i++) { - if(i%4 === 0) { - console.log(i); - } -} \ No newline at end of file +for (let i = 1; i <= 12; i++) { + if (i % 4 === 0) { + console.log(i); + } +} diff --git a/lib/workspace/js/solutions/task9.js b/lib/workspace/js/solutions/task9.js index 3a0de6b..5a05267 100644 --- a/lib/workspace/js/solutions/task9.js +++ b/lib/workspace/js/solutions/task9.js @@ -1,9 +1,9 @@ let x = 1; -while(x<=50) { - if(x%5 === 0) { - console.log('Buzz'); - } else { - console.log(x); - } - x++; -} \ No newline at end of file +while (x <= 50) { + if (x % 5 === 0) { + console.log('Buzz'); + } else { + console.log(x); + } + x++; +} From 95a066cf4f3c69f93714bdfae21d85e5589d668a Mon Sep 17 00:00:00 2001 From: Simon Smale Date: Sat, 5 Oct 2019 11:25:16 +0100 Subject: [PATCH 17/19] Chore(Task list): adds the task number for readability --- src/workspace/js/tasks.json | 116 ++++++++++++++++++++---------------- 1 file changed, 63 insertions(+), 53 deletions(-) diff --git a/src/workspace/js/tasks.json b/src/workspace/js/tasks.json index 133e40e..f9cd2df 100644 --- a/src/workspace/js/tasks.json +++ b/src/workspace/js/tasks.json @@ -1,56 +1,66 @@ [ - { - "task": "Hey there folks, you have chosen JS Path! \n Here's your first task! All the best...\n Task 1:-\n Print Hello World to the console", - "op": "/solutions/task1.js" - }, - - { - "task": "Great! Now's let's move on to variables. Variables are used to store data values \n Task 2:-\n Declare a variable to store the value 18 and print the value.", - "op": "/solutions/task2.js" - }, - - { - "task": "Let's move on to strings. Strings represent a set of characters written within quotes. \n Task 3:-\n Declare a variable to store the value 'JS is cool!' and print it.", - "op": "/solutions/task3.js" - }, - - { - "task": "Keep it up! Let's move on to String methods. There are a variety of methods for string manipulation in JS. Some of them are: \n 1. length - To find the length of the string. \n 2. indexOf() - Returns the first occurence of a specified text in a string. \n 3. slice() - extracts a part of a string and returns the extracted part. \n 4. replace() - replaces a specified value with another value in a string. \n 5. concat() - to join two or more strings. \n 6. trim() - removes the white space from both sides of the string. \n Task 4:-\n Obtain the following output for the string ' Hey, this is Task 4 of JS Path! ' \n Output: \n Length of the string \n Display the index of first occurence of 'Task' \n Slice the string for displaying 'JS' \n Replace JS with Python \n Concatenate '!' to the end of the string. \n Remove the whitespaces from the beginning and end of the string.", - "op": "/solutions/task4.js" - }, - - { - "task": "Impressive! Let's move on to the next topic: Operators. \n There are a variety of operators. Let's move on to Arithmetic Operators: +,-,*,/,%, **. \n Here's your task:\n Task 5:- \n Take 25 & 33 as your operands and print their sum, difference, product, quotient, remainder, 25^2.", - "op": "/solutions/task5.js" - }, - - { - "task": "Awesome! Let's move on to Comparison Operators. They are used to compare two values. They return true or false according to the value of their operands. They are: ==, ===, !=, >, <, >=, <=. Here's your task:\n Task 6:-\n Use 44 & 29 as your operands. Compare them using the Comparison operators in the same order and print the value which they return.", - "op": "/solutions/task6.js" - }, - - { - "task": "Now, let's move on to Logical Operators. They too return true or false according to the value of their operands. They are : \n && - returns true if both operands are true \n || - returns true if any of the operands are true \n ! - negates whatever the statement inside is. \n Here's your task: \n Task 7:- \n Use 34,23,1 as your operands. Check whether\n 1. 34>23 and 34<1 \n 2. 34<23 or 34>1 \n 3. not 23<34", - "op":"/solutions/task7.js" - }, - - { - "task": "Great! Let's move on to Loops now. Loops are used to repeat the same code without writing it over and over again. \n Let's start with for loop. Syntax: \n for (initialization; condition; update)\n{// code block to be executed} \n Here's your task: \n Task 8:- \n Print the multiples of 4 from 1 to 12 using for loop.", - "op": "/solutions/task8.js" - }, - - { - "task": "Let's move on to another loop, the while loop, along with the if-else blocks. while loop is also an entry controlled loop, i.e, it checks the condition first before it starts executing. If-else blocks are used to compare the values and execute according to the conditions given. \n Syntax: \n while(condition) \n {block of statements; update statement;} \n Here's your task: \n Task 9:- \n Print the numbers from 1 to 50. Print Buzz if the number is a multiple of 5.", - "op": "/solutions/task9.js" - }, - - { - "task": "Great work! Let's move on to another loop, the do while loop. Unlike other loops, this one is an exit controlled loop, i.e, it executes at least once. It checks the condition only at the exit. \n Syntax: do{\n loop block\n}(while(condition)); \n Here's your task: \nTask 10:-\n Iterate through the numbers 1 to 20 and print whether the number is odd or even. \n Here's the sample output: \n 1 is odd. \n2 is even. ....\n20 is even.", - "op": "/solutions/task10.js" - }, - - { - "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." - } + { + // Task 1 + "task": "Hey there folks, you have chosen JS Path! \n Here's your first task! All the best...\n Task 1:-\n Print Hello World to the console", + "op": "/solutions/task1.js" + }, + { + // Task 2 + "task": "Great! Now's let's move on to variables. Variables are used to store data values \n Task 2:-\n Declare a variable to store the value 18 and print the value.", + "op": "/solutions/task2.js" + }, + + { + // Task 3 + "task": "Let's move on to strings. Strings represent a set of characters written within quotes. \n Task 3:-\n Declare a variable to store the value 'JS is cool!' and print it.", + "op": "/solutions/task3.js" + }, + + { + // Task 4 + "task": "Keep it up! Let's move on to String methods. There are a variety of methods for string manipulation in JS. Some of them are: \n 1. length - To find the length of the string. \n 2. indexOf() - Returns the first occurence of a specified text in a string. \n 3. slice() - extracts a part of a string and returns the extracted part. \n 4. replace() - replaces a specified value with another value in a string. \n 5. concat() - to join two or more strings. \n 6. trim() - removes the white space from both sides of the string. \n Task 4:-\n Obtain the following output for the string ' Hey, this is Task 4 of JS Path! ' \n Output: \n Length of the string \n Display the index of first occurence of 'Task' \n Slice the string for displaying 'JS' \n Replace JS with Python \n Concatenate '!' to the end of the string. \n Remove the whitespaces from the beginning and end of the string.", + "op": "/solutions/task4.js" + }, + + { + // Task 5 + "task": "Impressive! Let's move on to the next topic: Operators. \n There are a variety of operators. Let's move on to Arithmetic Operators: +,-,*,/,%, **. \n Here's your task:\n Task 5:- \n Take 25 & 33 as your operands and print their sum, difference, product, quotient, remainder, 25^2.", + "op": "/solutions/task5.js" + }, + + { + // Task 6 + "task": "Awesome! Let's move on to Comparison Operators. They are used to compare two values. They return true or false according to the value of their operands. They are: ==, ===, !=, >, <, >=, <=. Here's your task:\n Task 6:-\n Use 44 & 29 as your operands. Compare them using the Comparison operators in the same order and print the value which they return.", + "op": "/solutions/task6.js" + }, + + { + // Task 7 + "task": "Now, let's move on to Logical Operators. They too return true or false according to the value of their operands. They are : \n && - returns true if both operands are true \n || - returns true if any of the operands are true \n ! - negates whatever the statement inside is. \n Here's your task: \n Task 7:- \n Use 34,23,1 as your operands. Check whether\n 1. 34>23 and 34<1 \n 2. 34<23 or 34>1 \n 3. not 23<34", + "op": "/solutions/task7.js" + }, + + { + // Task 8 + "task": "Great! Let's move on to Loops now. Loops are used to repeat the same code without writing it over and over again. \n Let's start with for loop. Syntax: \n for (initialization; condition; update)\n{// code block to be executed} \n Here's your task: \n Task 8:- \n Print the multiples of 4 from 1 to 12 using for loop.", + "op": "/solutions/task8.js" + }, + + { + // Task 9 + "task": "Let's move on to another loop, the while loop, along with the if-else blocks. while loop is also an entry controlled loop, i.e, it checks the condition first before it starts executing. If-else blocks are used to compare the values and execute according to the conditions given. \n Syntax: \n while(condition) \n {block of statements; update statement;} \n Here's your task: \n Task 9:- \n Print the numbers from 1 to 50. Print Buzz if the number is a multiple of 5.", + "op": "/solutions/task9.js" + }, + + { + // Task 10 + "task": "Great work! Let's move on to another loop, the do while loop. Unlike other loops, this one is an exit controlled loop, i.e, it executes at least once. It checks the condition only at the exit. \n Syntax: do{\n loop block\n}(while(condition)); \n Here's your task: \nTask 10:-\n Iterate through the numbers 1 to 20 and print whether the number is odd or even. \n Here's the sample output: \n 1 is odd. \n2 is even. ....\n20 is even.", + "op": "/solutions/task10.js" + }, + + { + // Task 11 + "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." + } ] From 221991ac1f4c60f78b6997aaf488e8c5030530f2 Mon Sep 17 00:00:00 2001 From: Simon Smale Date: Sat, 5 Oct 2019 11:26:39 +0100 Subject: [PATCH 18/19] Fix(Task List): adds the missing answer for task 11 --- src/workspace/js/tasks.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/workspace/js/tasks.json b/src/workspace/js/tasks.json index f9cd2df..5b81746 100644 --- a/src/workspace/js/tasks.json +++ b/src/workspace/js/tasks.json @@ -61,6 +61,7 @@ { // Task 11 - "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." + "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.", + "op": "/solutions/task11.js" } ] From f7cc56e9e11254c36ddab60d0c3ef86251d86fa7 Mon Sep 17 00:00:00 2001 From: Simon Smale Date: Sat, 5 Oct 2019 12:06:23 +0100 Subject: [PATCH 19/19] Feat(Task 12): adds the 12th task and solution --- lib/workspace/js/solutions/task12.js | 6 ++++++ src/workspace/js/tasks.json | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 lib/workspace/js/solutions/task12.js diff --git a/lib/workspace/js/solutions/task12.js b/lib/workspace/js/solutions/task12.js new file mode 100644 index 0000000..29c1e14 --- /dev/null +++ b/lib/workspace/js/solutions/task12.js @@ -0,0 +1,6 @@ +function add(a, b) { + console.log(a + b); +} +add(1, 2); +add(10, 15); +add(100, 400); diff --git a/src/workspace/js/tasks.json b/src/workspace/js/tasks.json index 5b81746..5bf0c9a 100644 --- a/src/workspace/js/tasks.json +++ b/src/workspace/js/tasks.json @@ -63,5 +63,11 @@ // Task 11 "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.", "op": "/solutions/task11.js" - } + }, + + { + // Task 12 + "task": "Keep up the good work! The next topic we will cover is functions. Functions are sections of code that exicute other code and make it reuseable. \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 an function using the 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", + "op": "/solutions/task12.js" + } ]