From 7a1989c11f8cb522cdcd91edbcdb371816b65834 Mon Sep 17 00:00:00 2001 From: Tien Hoang Pham Date: Tue, 2 Apr 2019 00:33:12 +0300 Subject: [PATCH 1/9] Add exercise files --- students/hoang-pham/02-04-2019/ex1.js | 1 - students/hoang-pham/03-04-2019/ex1.js | 1 - students/hoang-pham/03-04-2019/ex2.js | 1 - students/rename-this-folder/ex1.js | 9 +++++++++ students/rename-this-folder/ex2.js | 11 +++++++++++ students/rename-this-folder/ex3.js | 10 ++++++++++ students/rename-this-folder/ex4.js | 9 +++++++++ 7 files changed, 39 insertions(+), 3 deletions(-) delete mode 100644 students/hoang-pham/02-04-2019/ex1.js delete mode 100644 students/hoang-pham/03-04-2019/ex1.js delete mode 100644 students/hoang-pham/03-04-2019/ex2.js create mode 100644 students/rename-this-folder/ex1.js create mode 100644 students/rename-this-folder/ex2.js create mode 100644 students/rename-this-folder/ex3.js create mode 100644 students/rename-this-folder/ex4.js diff --git a/students/hoang-pham/02-04-2019/ex1.js b/students/hoang-pham/02-04-2019/ex1.js deleted file mode 100644 index 4b63607..0000000 --- a/students/hoang-pham/02-04-2019/ex1.js +++ /dev/null @@ -1 +0,0 @@ -console.log('test content for ex1'); diff --git a/students/hoang-pham/03-04-2019/ex1.js b/students/hoang-pham/03-04-2019/ex1.js deleted file mode 100644 index 4b63607..0000000 --- a/students/hoang-pham/03-04-2019/ex1.js +++ /dev/null @@ -1 +0,0 @@ -console.log('test content for ex1'); diff --git a/students/hoang-pham/03-04-2019/ex2.js b/students/hoang-pham/03-04-2019/ex2.js deleted file mode 100644 index e536cc2..0000000 --- a/students/hoang-pham/03-04-2019/ex2.js +++ /dev/null @@ -1 +0,0 @@ -console.log('test content for ex2'); diff --git a/students/rename-this-folder/ex1.js b/students/rename-this-folder/ex1.js new file mode 100644 index 0000000..1c7fc89 --- /dev/null +++ b/students/rename-this-folder/ex1.js @@ -0,0 +1,9 @@ +/* +Write a JavaScript function to check whether an input is an array or not. + +Test Data : +console.log(isArray('w3resource')); // false +console.log(isArray([1, 2, 4, 0])); // true +*/ + + diff --git a/students/rename-this-folder/ex2.js b/students/rename-this-folder/ex2.js new file mode 100644 index 0000000..eb24fa7 --- /dev/null +++ b/students/rename-this-folder/ex2.js @@ -0,0 +1,11 @@ +/* +Write a JavaScript function to get the first element of an array. Passing a parameter 'n' will return the first 'n' elements of the array. + +Test Data :  +console.log(first([7, 9, 0, -2])); // 7 +console.log(first([],3)); // [] +console.log(first([7, 9, 0, -2],3)); // [7,9,0] +console.log(first([7, 9, 0, -2],6)); // [7, 9, 0, -2] +console.log(first([7, 9, 0, -2],-3)); // [] + +*/ \ No newline at end of file diff --git a/students/rename-this-folder/ex3.js b/students/rename-this-folder/ex3.js new file mode 100644 index 0000000..eb98a2a --- /dev/null +++ b/students/rename-this-folder/ex3.js @@ -0,0 +1,10 @@ +/* +Write a simple JavaScript program to join all elements of the following array into a string. + +Sample array : +var myText = ['This', 'is', 'not', 'working']; +joinArray(myText); + +Expected Output :  +This is not working + */ \ No newline at end of file diff --git a/students/rename-this-folder/ex4.js b/students/rename-this-folder/ex4.js new file mode 100644 index 0000000..72f98cc --- /dev/null +++ b/students/rename-this-folder/ex4.js @@ -0,0 +1,9 @@ +/* +ATM machines allow 4 or 6 digit PIN codes and PIN codes cannot contain anything but exactly 4 digits or exactly 6 digits. If the function is passed a valid PIN string, return true, else return false. + +validatePIN(1234); // false +validatePIN(00004324); // false +validatePIN('2312'); // true +validatePin('asd123'); // false +validatePin('000010'); // true + */ \ No newline at end of file From 4c7ab8a21db34a8cd97f098a282ffcb8d53511d4 Mon Sep 17 00:00:00 2001 From: Tien Hoang Pham Date: Tue, 2 Apr 2019 00:45:44 +0300 Subject: [PATCH 2/9] rename exercise folder to copy-and-rename --- students/{rename-this-folder => copy-and-rename}/ex1.js | 0 students/{rename-this-folder => copy-and-rename}/ex2.js | 0 students/{rename-this-folder => copy-and-rename}/ex3.js | 0 students/{rename-this-folder => copy-and-rename}/ex4.js | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename students/{rename-this-folder => copy-and-rename}/ex1.js (100%) rename students/{rename-this-folder => copy-and-rename}/ex2.js (100%) rename students/{rename-this-folder => copy-and-rename}/ex3.js (100%) rename students/{rename-this-folder => copy-and-rename}/ex4.js (100%) diff --git a/students/rename-this-folder/ex1.js b/students/copy-and-rename/ex1.js similarity index 100% rename from students/rename-this-folder/ex1.js rename to students/copy-and-rename/ex1.js diff --git a/students/rename-this-folder/ex2.js b/students/copy-and-rename/ex2.js similarity index 100% rename from students/rename-this-folder/ex2.js rename to students/copy-and-rename/ex2.js diff --git a/students/rename-this-folder/ex3.js b/students/copy-and-rename/ex3.js similarity index 100% rename from students/rename-this-folder/ex3.js rename to students/copy-and-rename/ex3.js diff --git a/students/rename-this-folder/ex4.js b/students/copy-and-rename/ex4.js similarity index 100% rename from students/rename-this-folder/ex4.js rename to students/copy-and-rename/ex4.js From f16de4fa7958acb4bd49073b131b9b1ce6b5a99f Mon Sep 17 00:00:00 2001 From: Tien Hoang Pham Date: Tue, 2 Apr 2019 12:28:35 +0300 Subject: [PATCH 3/9] Add sample solutions --- students/test-student/ex1.js | 12 ++++++++++++ students/test-student/ex2.js | 29 +++++++++++++++++++++++++++++ students/test-student/ex3.js | 26 ++++++++++++++++++++++++++ students/test-student/ex4.js | 21 +++++++++++++++++++++ 4 files changed, 88 insertions(+) create mode 100644 students/test-student/ex1.js create mode 100644 students/test-student/ex2.js create mode 100644 students/test-student/ex3.js create mode 100644 students/test-student/ex4.js diff --git a/students/test-student/ex1.js b/students/test-student/ex1.js new file mode 100644 index 0000000..dfee6ff --- /dev/null +++ b/students/test-student/ex1.js @@ -0,0 +1,12 @@ +/* +Write a JavaScript function to check whether an input is an array or not. + +Test Data : +console.log(isArray('w3resource')); // false +console.log(isArray([1, 2, 4, 0])); // true +*/ + +function isArray(input){ + return Array.isArray(input); +} + diff --git a/students/test-student/ex2.js b/students/test-student/ex2.js new file mode 100644 index 0000000..8f03f61 --- /dev/null +++ b/students/test-student/ex2.js @@ -0,0 +1,29 @@ +/* +Write a JavaScript function to get the first element of an array. Passing a parameter 'n' will return the first 'n' elements of the array. + +Test Data :  +console.log(first([7, 9, 0, -2])); // 7 +console.log(first([],3)); // [] +console.log(first([7, 9, 0, -2],3)); // [7,9,0] +console.log(first([7, 9, 0, -2],6)); // [7, 9, 0, -2] +console.log(first([7, 9, 0, -2],-3)); // [] + +*/ +function first(input1, input2){ + if (!Array.isArray(input1)) { + return; + } else if (input1 === []) { // array can be empty >> return empty array + return []; + //second parameter is not given >> return the first element of the array + } else if (typeof(input2) === 'undefined' || input2 === null) { + return input1[0]; + // array has less number of elements than requested >> return all possibilities + } else if (input1.length <= input2) { + return input1; + } else if (input2 < 0) { //second parameter is negative >> return emtpy array + return []; + } else { + return input1.splice(0, input2); + } +} + diff --git a/students/test-student/ex3.js b/students/test-student/ex3.js new file mode 100644 index 0000000..648b77d --- /dev/null +++ b/students/test-student/ex3.js @@ -0,0 +1,26 @@ +/* +Write a simple JavaScript program to join all elements of the following array into a string. + +Sample array : +var myText = ['This', 'is', 'not', 'working']; +joinArray(myText); + +Expected Output :  +This is not working + */ + +function joinArray(input) { + var index = 0, + result = ''; + + while(index < input.length){ + result = result + ' ' + input[index]; + index++; + } + + return result; +} + +function joinArray(input) { + return input.join(' '); +} \ No newline at end of file diff --git a/students/test-student/ex4.js b/students/test-student/ex4.js new file mode 100644 index 0000000..124b26b --- /dev/null +++ b/students/test-student/ex4.js @@ -0,0 +1,21 @@ +/* +ATM machines allow 4 or 6 digit PIN codes and PIN codes cannot contain anything but exactly 4 digits or exactly 6 digits. If the function is passed a valid PIN string, return true, else return false. + +validatePIN(1234); // false +validatePIN(00004324); // false +validatePIN('2312'); // true +validatePin('asd123'); // false +validatePin('000010'); // true + */ + +function validatePIN(input) { + if (typeof(input) !== 'string') { + return false; + } + + // it is a number Number(input) returns false if it is not entirely a number + // make sure it contains no dot input.indexOf('.') returns value of greater + // than -1 if found a dot + // make sure it has length of either 4 or 6 + // input.length === 4 || input.length === 6 +} From 93863c4ef4b8b3fdc86b8595f5273c70f32d7356 Mon Sep 17 00:00:00 2001 From: Tien Hoang Pham Date: Wed, 3 Apr 2019 10:27:12 +0300 Subject: [PATCH 4/9] add exercise files --- students/copy-and-rename/ex1-sample.js | 0 students/copy-and-rename/ex1.js | 9 ----- students/copy-and-rename/ex2.js | 11 ------ students/copy-and-rename/ex3.js | 10 ------ students/copy-and-rename/ex4.js | 9 ----- students/copy-and-rename/questions.txt | 50 ++++++++++++++++++++++++++ students/test-student/ex1.js | 12 ------- students/test-student/ex2.js | 29 --------------- students/test-student/ex3.js | 26 -------------- students/test-student/ex4.js | 21 ----------- 10 files changed, 50 insertions(+), 127 deletions(-) create mode 100644 students/copy-and-rename/ex1-sample.js delete mode 100644 students/copy-and-rename/ex1.js delete mode 100644 students/copy-and-rename/ex2.js delete mode 100644 students/copy-and-rename/ex3.js delete mode 100644 students/copy-and-rename/ex4.js create mode 100644 students/copy-and-rename/questions.txt delete mode 100644 students/test-student/ex1.js delete mode 100644 students/test-student/ex2.js delete mode 100644 students/test-student/ex3.js delete mode 100644 students/test-student/ex4.js diff --git a/students/copy-and-rename/ex1-sample.js b/students/copy-and-rename/ex1-sample.js new file mode 100644 index 0000000..e69de29 diff --git a/students/copy-and-rename/ex1.js b/students/copy-and-rename/ex1.js deleted file mode 100644 index 1c7fc89..0000000 --- a/students/copy-and-rename/ex1.js +++ /dev/null @@ -1,9 +0,0 @@ -/* -Write a JavaScript function to check whether an input is an array or not. - -Test Data : -console.log(isArray('w3resource')); // false -console.log(isArray([1, 2, 4, 0])); // true -*/ - - diff --git a/students/copy-and-rename/ex2.js b/students/copy-and-rename/ex2.js deleted file mode 100644 index eb24fa7..0000000 --- a/students/copy-and-rename/ex2.js +++ /dev/null @@ -1,11 +0,0 @@ -/* -Write a JavaScript function to get the first element of an array. Passing a parameter 'n' will return the first 'n' elements of the array. - -Test Data :  -console.log(first([7, 9, 0, -2])); // 7 -console.log(first([],3)); // [] -console.log(first([7, 9, 0, -2],3)); // [7,9,0] -console.log(first([7, 9, 0, -2],6)); // [7, 9, 0, -2] -console.log(first([7, 9, 0, -2],-3)); // [] - -*/ \ No newline at end of file diff --git a/students/copy-and-rename/ex3.js b/students/copy-and-rename/ex3.js deleted file mode 100644 index eb98a2a..0000000 --- a/students/copy-and-rename/ex3.js +++ /dev/null @@ -1,10 +0,0 @@ -/* -Write a simple JavaScript program to join all elements of the following array into a string. - -Sample array : -var myText = ['This', 'is', 'not', 'working']; -joinArray(myText); - -Expected Output :  -This is not working - */ \ No newline at end of file diff --git a/students/copy-and-rename/ex4.js b/students/copy-and-rename/ex4.js deleted file mode 100644 index 72f98cc..0000000 --- a/students/copy-and-rename/ex4.js +++ /dev/null @@ -1,9 +0,0 @@ -/* -ATM machines allow 4 or 6 digit PIN codes and PIN codes cannot contain anything but exactly 4 digits or exactly 6 digits. If the function is passed a valid PIN string, return true, else return false. - -validatePIN(1234); // false -validatePIN(00004324); // false -validatePIN('2312'); // true -validatePin('asd123'); // false -validatePin('000010'); // true - */ \ No newline at end of file diff --git a/students/copy-and-rename/questions.txt b/students/copy-and-rename/questions.txt new file mode 100644 index 0000000..1430e34 --- /dev/null +++ b/students/copy-and-rename/questions.txt @@ -0,0 +1,50 @@ +1. Write a JavaScript program that accept two integers and display the larger. +2. Write a JavaScript conditional statement to find the sign of product of three numbers. Display an alert box with the specified sign. +Sample numbers : 3, -7, 2 +Output : The sign is - +3. Write a JavaScript conditional statement to sort three numbers. Display an alert box to show the result. +Sample numbers : 0, -1, 4 +Output : 4, 0, -1 +4. Write a JavaScript conditional statement to find the largest of five numbers. Display an alert box to show the result. +Sample numbers : -5, -2, -6, 0, -1 +Output : 0 +5. Write a JavaScript for loop that will iterate from 0 to 15. For each iteration, it will check if the current number is odd or even, and display a message to the screen. +Sample Output : +"0 is even" +"1 is odd" +"2 is even" +---------- +---------- +6. Write a JavaScript program which compute, the average marks of the following students Then, this average is used to determine the corresponding grade. + +Student Name Marks +David 80 +Vinoth 77 +Divya 88 +Ishitha 95 +Thomas 68 + +The grades are computed as follows: +Range Grade +<60 F +<70 D +<80 C +<90 B +<100 A + +7. Write a JavaScript program which iterates the integers from 1 to 100. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz". +8. According to Wikipedia a happy number is defined by the following process: +"Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which does not include 1. Those numbers for which this process ends in 1 are happy numbers, while those that do not end in 1 are unhappy numbers (or sad numbers)". +Write a JavaScript program to find and print the first 5 happy numbers. +9. Write a JavaScript program to find the armstrong numbers of 3 digits. +Note: An Armstrong number of three digits is an integer such that the sum of the cubes of its digits is equal to the number itself. For example, 371 is an Armstrong number since 3**3 + 7**3 + 1**3 = 371. +10. Write a JavaScript program to construct the following pattern, using a nested for loop. +* +* * +* * * +* * * * +* * * * * +11. Write a JavaScript program to compute the greatest common divisor (GCD) of two positive integers. +12. Write a JavaScript program to sum the multiples of 3 and 5 under 1000. + + diff --git a/students/test-student/ex1.js b/students/test-student/ex1.js deleted file mode 100644 index dfee6ff..0000000 --- a/students/test-student/ex1.js +++ /dev/null @@ -1,12 +0,0 @@ -/* -Write a JavaScript function to check whether an input is an array or not. - -Test Data : -console.log(isArray('w3resource')); // false -console.log(isArray([1, 2, 4, 0])); // true -*/ - -function isArray(input){ - return Array.isArray(input); -} - diff --git a/students/test-student/ex2.js b/students/test-student/ex2.js deleted file mode 100644 index 8f03f61..0000000 --- a/students/test-student/ex2.js +++ /dev/null @@ -1,29 +0,0 @@ -/* -Write a JavaScript function to get the first element of an array. Passing a parameter 'n' will return the first 'n' elements of the array. - -Test Data :  -console.log(first([7, 9, 0, -2])); // 7 -console.log(first([],3)); // [] -console.log(first([7, 9, 0, -2],3)); // [7,9,0] -console.log(first([7, 9, 0, -2],6)); // [7, 9, 0, -2] -console.log(first([7, 9, 0, -2],-3)); // [] - -*/ -function first(input1, input2){ - if (!Array.isArray(input1)) { - return; - } else if (input1 === []) { // array can be empty >> return empty array - return []; - //second parameter is not given >> return the first element of the array - } else if (typeof(input2) === 'undefined' || input2 === null) { - return input1[0]; - // array has less number of elements than requested >> return all possibilities - } else if (input1.length <= input2) { - return input1; - } else if (input2 < 0) { //second parameter is negative >> return emtpy array - return []; - } else { - return input1.splice(0, input2); - } -} - diff --git a/students/test-student/ex3.js b/students/test-student/ex3.js deleted file mode 100644 index 648b77d..0000000 --- a/students/test-student/ex3.js +++ /dev/null @@ -1,26 +0,0 @@ -/* -Write a simple JavaScript program to join all elements of the following array into a string. - -Sample array : -var myText = ['This', 'is', 'not', 'working']; -joinArray(myText); - -Expected Output :  -This is not working - */ - -function joinArray(input) { - var index = 0, - result = ''; - - while(index < input.length){ - result = result + ' ' + input[index]; - index++; - } - - return result; -} - -function joinArray(input) { - return input.join(' '); -} \ No newline at end of file diff --git a/students/test-student/ex4.js b/students/test-student/ex4.js deleted file mode 100644 index 124b26b..0000000 --- a/students/test-student/ex4.js +++ /dev/null @@ -1,21 +0,0 @@ -/* -ATM machines allow 4 or 6 digit PIN codes and PIN codes cannot contain anything but exactly 4 digits or exactly 6 digits. If the function is passed a valid PIN string, return true, else return false. - -validatePIN(1234); // false -validatePIN(00004324); // false -validatePIN('2312'); // true -validatePin('asd123'); // false -validatePin('000010'); // true - */ - -function validatePIN(input) { - if (typeof(input) !== 'string') { - return false; - } - - // it is a number Number(input) returns false if it is not entirely a number - // make sure it contains no dot input.indexOf('.') returns value of greater - // than -1 if found a dot - // make sure it has length of either 4 or 6 - // input.length === 4 || input.length === 6 -} From 928fb72f8ed3d5f3854786a9dd89dd111b206ef4 Mon Sep 17 00:00:00 2001 From: Devendra Date: Wed, 3 Apr 2019 13:22:04 +0300 Subject: [PATCH 5/9] completed till 5 --- students/devendra-katwal/averageGrade.js | 0 students/devendra-katwal/display-larger.js | 10 +++++ students/devendra-katwal/ex1-sample.js | 0 students/devendra-katwal/findSign.js | 13 ++++++ students/devendra-katwal/largest.js | 10 +++++ students/devendra-katwal/oddEven.js | 22 ++++++++++ students/devendra-katwal/questions.txt | 51 ++++++++++++++++++++++ students/devendra-katwal/sort.js | 15 +++++++ 8 files changed, 121 insertions(+) create mode 100644 students/devendra-katwal/averageGrade.js create mode 100644 students/devendra-katwal/display-larger.js create mode 100644 students/devendra-katwal/ex1-sample.js create mode 100644 students/devendra-katwal/findSign.js create mode 100644 students/devendra-katwal/largest.js create mode 100644 students/devendra-katwal/oddEven.js create mode 100644 students/devendra-katwal/questions.txt create mode 100644 students/devendra-katwal/sort.js diff --git a/students/devendra-katwal/averageGrade.js b/students/devendra-katwal/averageGrade.js new file mode 100644 index 0000000..e69de29 diff --git a/students/devendra-katwal/display-larger.js b/students/devendra-katwal/display-larger.js new file mode 100644 index 0000000..fd7683e --- /dev/null +++ b/students/devendra-katwal/display-larger.js @@ -0,0 +1,10 @@ +// 1. Write a JavaScript program that accept two integers and display the larger. +function displayLarger(arg1,arg2){ + if(arg1 >arg2){ + return arg1 + }else{ + return arg2 + } +} + +console.log(displayLarger(4,2)); \ No newline at end of file diff --git a/students/devendra-katwal/ex1-sample.js b/students/devendra-katwal/ex1-sample.js new file mode 100644 index 0000000..e69de29 diff --git a/students/devendra-katwal/findSign.js b/students/devendra-katwal/findSign.js new file mode 100644 index 0000000..53ac390 --- /dev/null +++ b/students/devendra-katwal/findSign.js @@ -0,0 +1,13 @@ +// 2. Write a JavaScript conditional statement to find the sign of product of three numbers. +// Display an alert box with the specified sign. + +function findSign(a,b,s){ + let product = a*b*s; + if (product < 0){ + return '-' + }else{ + return '+' + } +} + +console.log(findSign(1,-2,-4)); diff --git a/students/devendra-katwal/largest.js b/students/devendra-katwal/largest.js new file mode 100644 index 0000000..f4ed2e1 --- /dev/null +++ b/students/devendra-katwal/largest.js @@ -0,0 +1,10 @@ +// 4. Write a JavaScript conditional statement to find the largest of five numbers. Display an alert box to show the result. +// Sample numbers : -5, -2, -6, 0, -1 +// Output : 0 + +function largest(input){ + let big = input.sort((a,b)=>b-a); + return big[0]; +} +console.log(largest([-5, -2, -6, 0, -1 ])); +console.log(largest([-5,-2,-9])); \ No newline at end of file diff --git a/students/devendra-katwal/oddEven.js b/students/devendra-katwal/oddEven.js new file mode 100644 index 0000000..b31f4cb --- /dev/null +++ b/students/devendra-katwal/oddEven.js @@ -0,0 +1,22 @@ +// 5. Write a JavaScript for loop that will iterate from 0 to 15. For each iteration, it will check if the current number is odd or even, and display a message to the screen. +// Sample Output : +// "0 is even" +// "1 is odd" +// "2 is even" +// ---------- +// ---------- + +function oddEven(){ + var result = {}; + for(let i = 0; i<=15; i++){ + if(i%2 === 0 ){ + result[i] = 'even'; + }else if ( i === 0){ + result[i] = 'zero'; + }else{ + result[i] = 'odd'; + } + } + return result; +} +console.log(oddEven()); \ No newline at end of file diff --git a/students/devendra-katwal/questions.txt b/students/devendra-katwal/questions.txt new file mode 100644 index 0000000..1152e6c --- /dev/null +++ b/students/devendra-katwal/questions.txt @@ -0,0 +1,51 @@ +1. Write a JavaScript program that accept two integers and display the larger. +2. Write a JavaScript conditional statement to find the sign of product of three numbers. Display an alert box with the specified sign. +Sample numbers : 3, -7, 2 +Output : The sign is - +3. Write a JavaScript conditional statement to sort three numbers. Display an alert box to show the result. +Sample numbers : 0, -1, 4 +Output : 4, 0, -1 +4. Write a JavaScript conditional statement to find the largest of five numbers. Display an alert box to show the result. +Sample numbers : -5, -2, -6, 0, -1 +Output : 0 +5. Write a JavaScript for loop that will iterate from 0 to 15. For each iteration, it will check if the current number is odd or even, and display a message to the screen. +Sample Output : +"0 is even" +"1 is odd" +"2 is even" +---------- +---------- +6. Write a JavaScript program which compute, the average marks of the following students Then, +this average is used to determine the corresponding grade. + +Student Name Marks +David 80 +Vinoth 77 +Divya 88 +Ishitha 95 +Thomas 68 + +The grades are computed as follows: +Range Grade +<60 F +<70 D +<80 C +<90 B +<100 A + +7. Write a JavaScript program which iterates the integers from 1 to 100. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz". +8. According to Wikipedia a happy number is defined by the following process: +"Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which does not include 1. Those numbers for which this process ends in 1 are happy numbers, while those that do not end in 1 are unhappy numbers (or sad numbers)". +Write a JavaScript program to find and print the first 5 happy numbers. +9. Write a JavaScript program to find the armstrong numbers of 3 digits. +Note: An Armstrong number of three digits is an integer such that the sum of the cubes of its digits is equal to the number itself. For example, 371 is an Armstrong number since 3**3 + 7**3 + 1**3 = 371. +10. Write a JavaScript program to construct the following pattern, using a nested for loop. +* +* * +* * * +* * * * +* * * * * +11. Write a JavaScript program to compute the greatest common divisor (GCD) of two positive integers. +12. Write a JavaScript program to sum the multiples of 3 and 5 under 1000. + + diff --git a/students/devendra-katwal/sort.js b/students/devendra-katwal/sort.js new file mode 100644 index 0000000..13471c7 --- /dev/null +++ b/students/devendra-katwal/sort.js @@ -0,0 +1,15 @@ +// 3. Write a JavaScript conditional statement to sort three numbers. +// Display an alert box to show the result. +// Sample numbers : 0, -1, 4 +// Output : 4, 0, -1 + + +function sortItems(input){ + return input.sort(function(a,b){ + return b-a + }) +} + + + +console.log(sortItems([1,4,3])); \ No newline at end of file From ea1dacc394b1f70efbd70265477d0e6fd4e5bd1e Mon Sep 17 00:00:00 2001 From: Devendra Date: Wed, 3 Apr 2019 14:08:23 +0300 Subject: [PATCH 6/9] completed till 5 --- students/devendra-katwal/averageGrade.js | 34 ++++++++++++++++++++++++ students/devendra-katwal/largest.js | 5 ++-- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/students/devendra-katwal/averageGrade.js b/students/devendra-katwal/averageGrade.js index e69de29..96daab3 100644 --- a/students/devendra-katwal/averageGrade.js +++ b/students/devendra-katwal/averageGrade.js @@ -0,0 +1,34 @@ +// 6. Write a JavaScript program which compute, the average marks of the following students Then, +// this average is used to determine the corresponding grade. + +// Student Name Marks +// David 80 +// Vinoth 77 +// Divya 88 +// Ishitha 95 +// Thomas 68 + +// The grades are computed as follows: +// Range Grade +// <60 F +// <70 D +// <80 C +// <90 B +// <100 A' + +let marks = { + +'David':80, +'Vinoth':77, +'Divya':88, +'Ishitha' :95, +'Thomas' :68, +} +function gradeCalculator(input){ +let num = [] +for(item in input){ + num.push(input[item]); +} +return num +} +console.log(gradeCalculator(marks)); \ No newline at end of file diff --git a/students/devendra-katwal/largest.js b/students/devendra-katwal/largest.js index f4ed2e1..919dc3e 100644 --- a/students/devendra-katwal/largest.js +++ b/students/devendra-katwal/largest.js @@ -1,10 +1,11 @@ // 4. Write a JavaScript conditional statement to find the largest of five numbers. Display an alert box to show the result. // Sample numbers : -5, -2, -6, 0, -1 // Output : 0 - +let a = [-5, -2, -6, 0, -1 ] function largest(input){ let big = input.sort((a,b)=>b-a); return big[0]; } -console.log(largest([-5, -2, -6, 0, -1 ])); +let b = largest(a); +console.log(b); console.log(largest([-5,-2,-9])); \ No newline at end of file From 771d4c6aa805c728a41cb79bcdda31bdce668c34 Mon Sep 17 00:00:00 2001 From: Gaurab KC <35660893+kecyGaurab@users.noreply.github.com> Date: Wed, 3 Apr 2019 14:17:44 +0300 Subject: [PATCH 7/9] solved till 2 --- Lect4ArraEx/ex1-sample.js | 11 +++++++++ Lect4ArraEx/ex2.js | 14 +++++++++++ Lect4ArraEx/ex3.js | 21 ++++++++++++++++ Lect4ArraEx/questions.txt | 50 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 96 insertions(+) create mode 100644 Lect4ArraEx/ex1-sample.js create mode 100644 Lect4ArraEx/ex2.js create mode 100644 Lect4ArraEx/ex3.js create mode 100644 Lect4ArraEx/questions.txt diff --git a/Lect4ArraEx/ex1-sample.js b/Lect4ArraEx/ex1-sample.js new file mode 100644 index 0000000..31e2467 --- /dev/null +++ b/Lect4ArraEx/ex1-sample.js @@ -0,0 +1,11 @@ +// Write a JavaScript program that accept two integers and display the larger. + +function largerInteger(a,b){ + if (a > b){ + return a; + } + else{ + return b; + } +} +console.log(largerInteger(4,-5)); diff --git a/Lect4ArraEx/ex2.js b/Lect4ArraEx/ex2.js new file mode 100644 index 0000000..a6d91d0 --- /dev/null +++ b/Lect4ArraEx/ex2.js @@ -0,0 +1,14 @@ +// Write a JavaScript conditional statement to find the sign of product of three numbers. Display an alert box with the specified sign. +//Sample numbers : 3, -7, 2 +//Output : The sign is - // + +function productSign(a,b,c){ + var product = a*b*c + if(product < 0){ + alert("-"); + } + else{ + alert("+"); + } +} +console.log(productSign(2,4,8)); diff --git a/Lect4ArraEx/ex3.js b/Lect4ArraEx/ex3.js new file mode 100644 index 0000000..b473afb --- /dev/null +++ b/Lect4ArraEx/ex3.js @@ -0,0 +1,21 @@ +// Write a JavaScript conditional statement to sort three numbers. Display an alert box to show the result. +//Sample numbers : 0, -1, 4 +//Output : 4, 0, -1 // + +function sortDescending(arr){ + for (i = 1; i < arr.length; i++){ + for (j = 0; j < i; j++ ){ + if( arr[i] >= arr[j]){ + var x = arr[i]; + arr[i] = arr[j]; + arr[j] = x; + } + + } + return arr; + }} + + + + +console.log(sortDescending([1,4,7])); diff --git a/Lect4ArraEx/questions.txt b/Lect4ArraEx/questions.txt new file mode 100644 index 0000000..1430e34 --- /dev/null +++ b/Lect4ArraEx/questions.txt @@ -0,0 +1,50 @@ +1. Write a JavaScript program that accept two integers and display the larger. +2. Write a JavaScript conditional statement to find the sign of product of three numbers. Display an alert box with the specified sign. +Sample numbers : 3, -7, 2 +Output : The sign is - +3. Write a JavaScript conditional statement to sort three numbers. Display an alert box to show the result. +Sample numbers : 0, -1, 4 +Output : 4, 0, -1 +4. Write a JavaScript conditional statement to find the largest of five numbers. Display an alert box to show the result. +Sample numbers : -5, -2, -6, 0, -1 +Output : 0 +5. Write a JavaScript for loop that will iterate from 0 to 15. For each iteration, it will check if the current number is odd or even, and display a message to the screen. +Sample Output : +"0 is even" +"1 is odd" +"2 is even" +---------- +---------- +6. Write a JavaScript program which compute, the average marks of the following students Then, this average is used to determine the corresponding grade. + +Student Name Marks +David 80 +Vinoth 77 +Divya 88 +Ishitha 95 +Thomas 68 + +The grades are computed as follows: +Range Grade +<60 F +<70 D +<80 C +<90 B +<100 A + +7. Write a JavaScript program which iterates the integers from 1 to 100. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz". +8. According to Wikipedia a happy number is defined by the following process: +"Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which does not include 1. Those numbers for which this process ends in 1 are happy numbers, while those that do not end in 1 are unhappy numbers (or sad numbers)". +Write a JavaScript program to find and print the first 5 happy numbers. +9. Write a JavaScript program to find the armstrong numbers of 3 digits. +Note: An Armstrong number of three digits is an integer such that the sum of the cubes of its digits is equal to the number itself. For example, 371 is an Armstrong number since 3**3 + 7**3 + 1**3 = 371. +10. Write a JavaScript program to construct the following pattern, using a nested for loop. +* +* * +* * * +* * * * +* * * * * +11. Write a JavaScript program to compute the greatest common divisor (GCD) of two positive integers. +12. Write a JavaScript program to sum the multiples of 3 and 5 under 1000. + + From 5675d8bfb46d23bcea9caf3737ff447f6c909269 Mon Sep 17 00:00:00 2001 From: Zeeshan Ahmad <46978244+zeeshanahmad25@users.noreply.github.com> Date: Wed, 3 Apr 2019 14:21:34 +0300 Subject: [PATCH 8/9] Ex1-5 completed --- students/zeeshan-ahmad/ex1-sample.js | 3 ++ students/zeeshan-ahmad/ex1.js | 1 + students/zeeshan-ahmad/ex2.js | 18 ++++++++++ students/zeeshan-ahmad/ex3.js | 7 ++++ students/zeeshan-ahmad/ex4.js | 8 +++++ students/zeeshan-ahmad/ex5.js | 25 ++++++++++++++ students/zeeshan-ahmad/questions.txt | 50 ++++++++++++++++++++++++++++ 7 files changed, 112 insertions(+) create mode 100644 students/zeeshan-ahmad/ex1-sample.js create mode 100644 students/zeeshan-ahmad/ex1.js create mode 100644 students/zeeshan-ahmad/ex2.js create mode 100644 students/zeeshan-ahmad/ex3.js create mode 100644 students/zeeshan-ahmad/ex4.js create mode 100644 students/zeeshan-ahmad/ex5.js create mode 100644 students/zeeshan-ahmad/questions.txt diff --git a/students/zeeshan-ahmad/ex1-sample.js b/students/zeeshan-ahmad/ex1-sample.js new file mode 100644 index 0000000..d6fe0dd --- /dev/null +++ b/students/zeeshan-ahmad/ex1-sample.js @@ -0,0 +1,3 @@ +// Write a JavaScript program that accept two integers and display the larger. + +console.log(Math.max(10,20)) diff --git a/students/zeeshan-ahmad/ex1.js b/students/zeeshan-ahmad/ex1.js new file mode 100644 index 0000000..4b63607 --- /dev/null +++ b/students/zeeshan-ahmad/ex1.js @@ -0,0 +1 @@ +console.log('test content for ex1'); diff --git a/students/zeeshan-ahmad/ex2.js b/students/zeeshan-ahmad/ex2.js new file mode 100644 index 0000000..d9bd729 --- /dev/null +++ b/students/zeeshan-ahmad/ex2.js @@ -0,0 +1,18 @@ +/*Write a JavaScript conditional statement to + find the sign of product of three numbers. + Display an alert box with the specified sign. + +Sample numbers : 3, -7, 2 + +Output : The sign is -*/ + + +var myVar = function (a,b,c) { + + if ((a*b*c) < 0) { + alert("the sign is -"); +} +} + +myVar(3,7,2); + diff --git a/students/zeeshan-ahmad/ex3.js b/students/zeeshan-ahmad/ex3.js new file mode 100644 index 0000000..6ea8912 --- /dev/null +++ b/students/zeeshan-ahmad/ex3.js @@ -0,0 +1,7 @@ +/* Write a JavaScript conditional statement to sort three numbers. + Display an alert box to show the result. + +Sample numbers : 0, -1, 4 + +Output : 4, 0, -1 */ + diff --git a/students/zeeshan-ahmad/ex4.js b/students/zeeshan-ahmad/ex4.js new file mode 100644 index 0000000..69dcbce --- /dev/null +++ b/students/zeeshan-ahmad/ex4.js @@ -0,0 +1,8 @@ +/* +Write a JavaScript conditional statement to find the largest of five numbers. +Display an alert box to show the result. + +Sample numbers : -5, -2, -6, 0, -1 + +Output : 0 */ + diff --git a/students/zeeshan-ahmad/ex5.js b/students/zeeshan-ahmad/ex5.js new file mode 100644 index 0000000..f751e12 --- /dev/null +++ b/students/zeeshan-ahmad/ex5.js @@ -0,0 +1,25 @@ +/* +Write a JavaScript for loop that will iterate from 0 to 15. For each iteration, +it will check if the current number is odd or even, +and display a message to the screen. + +Sample Output : + +"0 is even" + +"1 is odd" + +"2 is even" */ + +for (var x=0; x<=15; x++) { + if (x === 0) { + console.log(x + " is even"); + } + else if (x % 2 === 0) { + console.log(x + " is even"); + } + else { + console.log(x + " is odd"); + } +} + diff --git a/students/zeeshan-ahmad/questions.txt b/students/zeeshan-ahmad/questions.txt new file mode 100644 index 0000000..1430e34 --- /dev/null +++ b/students/zeeshan-ahmad/questions.txt @@ -0,0 +1,50 @@ +1. Write a JavaScript program that accept two integers and display the larger. +2. Write a JavaScript conditional statement to find the sign of product of three numbers. Display an alert box with the specified sign. +Sample numbers : 3, -7, 2 +Output : The sign is - +3. Write a JavaScript conditional statement to sort three numbers. Display an alert box to show the result. +Sample numbers : 0, -1, 4 +Output : 4, 0, -1 +4. Write a JavaScript conditional statement to find the largest of five numbers. Display an alert box to show the result. +Sample numbers : -5, -2, -6, 0, -1 +Output : 0 +5. Write a JavaScript for loop that will iterate from 0 to 15. For each iteration, it will check if the current number is odd or even, and display a message to the screen. +Sample Output : +"0 is even" +"1 is odd" +"2 is even" +---------- +---------- +6. Write a JavaScript program which compute, the average marks of the following students Then, this average is used to determine the corresponding grade. + +Student Name Marks +David 80 +Vinoth 77 +Divya 88 +Ishitha 95 +Thomas 68 + +The grades are computed as follows: +Range Grade +<60 F +<70 D +<80 C +<90 B +<100 A + +7. Write a JavaScript program which iterates the integers from 1 to 100. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz". +8. According to Wikipedia a happy number is defined by the following process: +"Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which does not include 1. Those numbers for which this process ends in 1 are happy numbers, while those that do not end in 1 are unhappy numbers (or sad numbers)". +Write a JavaScript program to find and print the first 5 happy numbers. +9. Write a JavaScript program to find the armstrong numbers of 3 digits. +Note: An Armstrong number of three digits is an integer such that the sum of the cubes of its digits is equal to the number itself. For example, 371 is an Armstrong number since 3**3 + 7**3 + 1**3 = 371. +10. Write a JavaScript program to construct the following pattern, using a nested for loop. +* +* * +* * * +* * * * +* * * * * +11. Write a JavaScript program to compute the greatest common divisor (GCD) of two positive integers. +12. Write a JavaScript program to sum the multiples of 3 and 5 under 1000. + + From cd09c272e4a5833688a32bad6b3764ae8eaab334 Mon Sep 17 00:00:00 2001 From: Akeundo <48980681+Akeundo@users.noreply.github.com> Date: Fri, 5 Apr 2019 08:20:46 +0300 Subject: [PATCH 9/9] Lec 5 solutions to some of lecture 5 exercises --- students/valantin.akeundo/ex1-sample.js | 175 ++++++++++++++++++++++++ students/valantin.akeundo/questions.txt | 91 ++++++++++++ 2 files changed, 266 insertions(+) create mode 100644 students/valantin.akeundo/ex1-sample.js create mode 100644 students/valantin.akeundo/questions.txt diff --git a/students/valantin.akeundo/ex1-sample.js b/students/valantin.akeundo/ex1-sample.js new file mode 100644 index 0000000..c00164a --- /dev/null +++ b/students/valantin.akeundo/ex1-sample.js @@ -0,0 +1,175 @@ +1. Write a JavaScript program that accept two integers and display the larger. +2. Write a JavaScript conditional statement to find the sign of product of three numbers.Display an alert box with the specified sign. +Sample numbers: 3, -7, 2 +Output: The sign is - + 3. Write a JavaScript conditional statement to sort three numbers.Display an alert box to show the result. +Sample numbers: 0, -1, 4 +Output: 4, 0, -1 +4. Write a JavaScript conditional statement to find the largest of five numbers.Display an alert box to show the result. +Sample numbers: -5, -2, -6, 0, -1 +Output: 0 +5. Write a JavaScript +for loop that will iterate from 0 to 15. For each iteration, it will check +if the current number is odd or even, and display a message to the screen. +Sample Output: + "0 is even" +"1 is odd" +"2 is even" +-- -- -- -- -- +-- -- -- -- -- +6. Write a JavaScript program which compute, the average marks of the following students Then, this average is used to determine the corresponding grade. + +Student Name Marks +David 80 +Vinoth 77 +Divya 88 +Ishitha 95 +Thomas 68 + +The grades are computed as follows: + Range Grade < + 60 F < + 70 D < + 80 C < + 90 B < + 100 A + +7. Write a JavaScript program which iterates the integers from 1 to 100. But +for multiples of three print "Fizz" +instead of the number and +for the multiples of five print "Buzz".For numbers which are multiples of both three and five print "FizzBuzz". +8. According to Wikipedia a happy number is defined by the following process: + "Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which does not include 1. Those numbers for which this process ends in 1 are happy numbers, while those that do not end in 1 are unhappy numbers (or sad numbers)". +Write a JavaScript program to find and print the first 5 happy numbers. +9. Write a JavaScript program to find the armstrong numbers of 3 digits. +Note: An Armstrong number of three digits is an integer such that the sum of the cubes of its digits is equal to the number itself.For example, 371 is an Armstrong number since 3 ** 3 + 7 ** 3 + 1 ** 3 = 371. +10. Write a JavaScript program to construct the following pattern, using a nested +for loop.* + * + * + * + * * + * + * * * + * + * * * * + 11. Write a JavaScript program to compute the greatest common divisor(GCD) of two positive integers. +12. Write a JavaScript program to sum the multiples of 3 and 5 under 1000. + +//solution 1 + +function integer(a, b) { + + if (a > 0 && b > 0 && a > b) { + document.write("The larger number is " + a); + } else if (a > 0 && b > 0 && a < b) { + document.write("The larger number is " + b); + } else if (a === b && a > 0 && b > 0) { + document.write("Both numbers are equal!") + } else { + document.write("Please add an integer!"); + + } +} + +integer(2, 4); +integer(3, 3); +integer(-2, -6); + +// Solution 2 get product of 3 numbers and after compare results with zero. if results is > 0 then alert + else alert - + +function getProduct(x, y, z) { + + + if (x + y + z >= 0) { + alert("The sign is +"); + } else if (x < 0 && y < 0 && z < 0) { + alert("The sign is +"); + } else if (x > 0 && y < 0 && z < 0) { + alert("The sign is +"); + } else if (x < 0 && y > 0 && z < 0) { + alert("The sign is +"); + } else { + alert("The sign is -"); + } + +} +getProduct(3, -7, 2); + +//solution 3 + + +function get.Max(a, b, c); { + + if (a > 0 && b > 0 && c > 0 && a > b > c) { + alert("The Max number is " + a); + } else if (a > 0 && b > 0 && c > 0 && b > c > a) { + alert("The Max number is " + b); + } else if (a > 0 && b > 0 && c > 0 && c > b > a) { + alert("The Max number is " + c); + + } else if (a === b === c && a > 0 && b > 0 && c > 0) { + alert("all 3 numbers are equal!") + } else { + alert("Please add another number!"); + + } +} +get.Max(2, 4, 8); +get.Max(3, 3, 3); +get.Max(-2, -6 - 9); + +//solution 5 + +var number = 0; +while (number <= 15) { + if (number % 2 === 0) { + console.log(number + " is even number"); + number = number + 1; + + } else { + console.log(number + " is odd number"); + number = number + 1; + } +} + +//solution 6 + +var students = [ + ['David', 80], + ['Vinoth', 77], + ['Divya', 88], + ['Ishitha', 95], + ['Thomas', 68] +]; + +var Avgmarks = 0; + +for (var i = 0; i < students.length; i++) { + Avgmarks += students[i][1]; + var avg = (Avgmarks / students.length); +} + +console.log("Average grade: " + (Avgmarks) / students.length); + +if (avg < 60) { + console.log("Grade : F"); +} else if (avg < 70) { + console.log("Grade : D"); +} else if (avg < 80) { + console.log("Grade : C"); +} else if (avg < 90) { + console.log("Grade : B"); +} else if (avg < 100) { + console.log("Grade : A"); +} + +// solution 12 + +var sum = 0; +for (var x = 0; x < 1000; x++) { + if (x % 3 === 0 || x % 5 === 0) { + sum += x; + } +} +console.log(sum); \ No newline at end of file diff --git a/students/valantin.akeundo/questions.txt b/students/valantin.akeundo/questions.txt new file mode 100644 index 0000000..0d0a1f9 --- /dev/null +++ b/students/valantin.akeundo/questions.txt @@ -0,0 +1,91 @@ +1. Write a JavaScript program that accept two integers and display the larger. +2. Write a JavaScript conditional statement to find the sign of product of three numbers. Display an alert box with the specified sign. +Sample numbers : 3, -7, 2 +Output : The sign is - +3. Write a JavaScript conditional statement to sort three numbers. Display an alert box to show the result. +Sample numbers : 0, -1, 4 +Output : 4, 0, -1 +4. Write a JavaScript conditional statement to find the largest of five numbers. Display an alert box to show the result. +Sample numbers : -5, -2, -6, 0, -1 +Output : 0 +5. Write a JavaScript for loop that will iterate from 0 to 15. For each iteration, it will check if the current number is odd or even, and display a message to the screen. +Sample Output : +"0 is even" +"1 is odd" +"2 is even" +---------- +---------- +6. Write a JavaScript program which compute, the average marks of the following students Then, this average is used to determine the corresponding grade. + +Student Name Marks +David 80 +Vinoth 77 +Divya 88 +Ishitha 95 +Thomas 68 + +The grades are computed as follows: +Range Grade +<60 F +<70 D +<80 C +<90 B +<100 A + +7. Write a JavaScript program which iterates the integers from 1 to 100. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz". +8. According to Wikipedia a happy number is defined by the following process: +"Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which does not include 1. Those numbers for which this process ends in 1 are happy numbers, while those that do not end in 1 are unhappy numbers (or sad numbers)". +Write a JavaScript program to find and print the first 5 happy numbers. +9. Write a JavaScript program to find the armstrong numbers of 3 digits. +Note: An Armstrong number of three digits is an integer such that the sum of the cubes of its digits is equal to the number itself. For example, 371 is an Armstrong number since 3**3 + 7**3 + 1**3 = 371. +10. Write a JavaScript program to construct the following pattern, using a nested for loop. +* +* * +* * * +* * * * +* * * * * +11. Write a JavaScript program to compute the greatest common divisor (GCD) of two positive integers. +12. Write a JavaScript program to sum the multiples of 3 and 5 under 1000. + +//solution 1 + +function integer(a,b) { + + if (a > 0 && b > 0 && a > b) { + document.write("The larger number is " + a ); + } else if (a > 0 && b > 0 && a < b) { + document.write("The larger number is " + b); + } else if (a === b && a > 0 && b > 0) { + document.write("Both numbers are equal!") + } else { + document.write("Please add an integer!"); + + } +} + +integer( 2, 4 ); +integer( 3, 3 ); +integer( -2, -6 ); + +// Solution 2 + +function getProduct(x, y, z) { + + + if (x + y + z >= 0) { + alert("The sign is +"); + } else if (x < 0 && y < 0 && z < 0) { + alert("The sign is +"); + } else if (x > 0 && y < 0 && z < 0) { + alert("The sign is +"); + } else if (x < 0 && y > 0 && z < 0) { + alert("The sign is +"); + } else { + alert("The sign is -"); + } + +} +getProduct(3, -7, 2); + + +