From eda5ea432026fc3fcd0d588c69c5a7ed1ffb0306 Mon Sep 17 00:00:00 2001 From: JohnMV13 Date: Fri, 8 Jun 2018 11:52:08 -0500 Subject: [PATCH 1/7] problem 1 --- app.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app.js b/app.js index 792e13b..3d694ee 100644 --- a/app.js +++ b/app.js @@ -13,7 +13,13 @@ Test this function by hand in the console to get it working, and when you think // Write your code here function sum(a, b) { + var result = a + b; + var array = [result]; + array[0]= result; + console.log(array); + array[1] = "The sum of " + a + " and " + b + " is " + result; + return array; } // Here is the test for sum(); uncomment it to run it From ab280d2511d5f2aaefa500956a2ec9c5944c7d53 Mon Sep 17 00:00:00 2001 From: JohnMV13 Date: Fri, 8 Jun 2018 13:52:47 -0500 Subject: [PATCH 2/7] Problem-2 --- app.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app.js b/app.js index 3d694ee..45b52fe 100644 --- a/app.js +++ b/app.js @@ -15,7 +15,6 @@ Test this function by hand in the console to get it working, and when you think function sum(a, b) { var result = a + b; var array = [result]; - array[0]= result; console.log(array); array[1] = "The sum of " + a + " and " + b + " is " + result; @@ -37,6 +36,11 @@ Test this function by hand in the console to get it working, and when you think // Write your code here function multiply(a, b) { + var product = a * b; + var array = [product]; + console.log(array); + + array[2] = "The product of " + a + " and " + b + " is " + product; } From 3bc1a2b57b8c1728d892382d1198fd7379d295db Mon Sep 17 00:00:00 2001 From: JohnMV13 Date: Fri, 8 Jun 2018 15:07:03 -0500 Subject: [PATCH 3/7] project-3 --- .vscode/settings.json | 2 ++ app.js | 17 +++++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..7a73a41 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,2 @@ +{ +} \ No newline at end of file diff --git a/app.js b/app.js index 45b52fe..c5499df 100644 --- a/app.js +++ b/app.js @@ -15,7 +15,7 @@ Test this function by hand in the console to get it working, and when you think function sum(a, b) { var result = a + b; var array = [result]; - console.log(array); + array[1] = "The sum of " + a + " and " + b + " is " + result; return array; @@ -38,9 +38,10 @@ Test this function by hand in the console to get it working, and when you think function multiply(a, b) { var product = a * b; var array = [product]; - console.log(array); + - array[2] = "The product of " + a + " and " + b + " is " + product; + array[1] = "The product of " + a + " and " + b + " is " + product; + return array; } @@ -61,8 +62,16 @@ IMPORTANT DETAIL: You may not use the arithmetic operators + and * in this funct Test this function by hand in the console to get it working, and when you think it is finished, uncomment the call for the testSumAndMultiply() function and see if the test passes.*/ // Write your code here -function sumAndMultiply(a, b, c) { +function sumAndMultiply(a, b, c) { + var absum = sum(a, b); + absum =sum(absum[0], c); + var array = [absum[0]]; + var abmul = multiply(a, b); + abmul = multiply(abmul[0], c); + array[1] = abmul[0]; + array[2] = "The sum of " + a + ", " + b + " and " + c + " is " + array +"."; + array[3] = "The product of " + a + ", " + b + " and " + c + " is " + array[1] + "."; } // Here is the test for sumAndMultiply(); uncomment it to run it From 425fd0c6cec0e8987943c21fdb6415e61cc162c4 Mon Sep 17 00:00:00 2001 From: JohnMV13 Date: Fri, 8 Jun 2018 16:58:28 -0500 Subject: [PATCH 4/7] problem-4 --- app.js | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/app.js b/app.js index c5499df..ebd4775 100644 --- a/app.js +++ b/app.js @@ -15,14 +15,13 @@ Test this function by hand in the console to get it working, and when you think function sum(a, b) { var result = a + b; var array = [result]; - - array[1] = "The sum of " + a + " and " + b + " is " + result; + array[1] = "The sum of " + a + " and " + b + " is " + result + "."; + return array; } - // Here is the test for sum(); uncomment it to run it -// testSum(4, 7); +testSum(4, 7); // Once you get the test passing, do an a-c-p cycle and synchronize the code between GitHub and your laptop. Don't forget to create a new branch for your work on the next question! @@ -40,13 +39,13 @@ function multiply(a, b) { var array = [product]; - array[1] = "The product of " + a + " and " + b + " is " + product; + array[1] = "The product of " + a + " and " + b + " is " + product +"."; return array; } // Here is the test for multiply(); uncomment it to run it -// testMultiply(5,9); +testMultiply(5,9); // Once you get the test passing, do an a-c-p cycle and synchronize the code between GitHub and your laptop. Don't forget to create a new branch for your work on the next question! @@ -70,12 +69,14 @@ function sumAndMultiply(a, b, c) { var abmul = multiply(a, b); abmul = multiply(abmul[0], c); array[1] = abmul[0]; - array[2] = "The sum of " + a + ", " + b + " and " + c + " is " + array +"."; - array[3] = "The product of " + a + ", " + b + " and " + c + " is " + array[1] + "."; + array[2] = a + " and " + b + " and " + c + " sum to " + array[0] +"."; + array[3] = "The product of " + a + " and " + b + " and " + c + " is " + array[1] + "."; + + return array; } // Here is the test for sumAndMultiply(); uncomment it to run it -// testSumAndMultiply(4,7,5); +testSumAndMultiply(4,7,5); // Once you get the test passing, do an a-c-p cycle and synchronize the code between GitHub and your laptop. Don't forget to create a new branch for your work on the next question! @@ -91,12 +92,21 @@ Test this function by hand in the console to get it working, and when you think // Write your code here function sumArray(sumArr) { + var sSum = 0 + for(var i = 0; i < sumArr.length; i++) { + var sSum= sum(sumArr[i], sSum)[0]; + console.log(sSum) + + } + var array = [sumArr] + array = sumArr + ' was passed in as an array of numbers, and ' + sSum + ' is their sum.'; + return array; } // Here is the test for sumArray(); uncomment it to run it -// testSumArray([2, 3, 4]); +testSumArray([2, 3, 4]); // Once you get the test passing, do an a-c-p cycle and synchronize the code between GitHub and your laptop. Don't forget to create a new branch for your work on the next question! From 00d6ce9a2b7d6f25626ae3dc7f191e4ebe8efb49 Mon Sep 17 00:00:00 2001 From: JohnMV13 Date: Fri, 8 Jun 2018 17:04:19 -0500 Subject: [PATCH 5/7] problem-4 --- app.js | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/app.js b/app.js index ebd4775..6a65e40 100644 --- a/app.js +++ b/app.js @@ -15,13 +15,14 @@ Test this function by hand in the console to get it working, and when you think function sum(a, b) { var result = a + b; var array = [result]; + - array[1] = "The sum of " + a + " and " + b + " is " + result + "."; - + array[1] = "The sum of " + a + " and " + b + " is " + result; return array; } + // Here is the test for sum(); uncomment it to run it -testSum(4, 7); +// testSum(4, 7); // Once you get the test passing, do an a-c-p cycle and synchronize the code between GitHub and your laptop. Don't forget to create a new branch for your work on the next question! @@ -39,13 +40,13 @@ function multiply(a, b) { var array = [product]; - array[1] = "The product of " + a + " and " + b + " is " + product +"."; + array[1] = "The product of " + a + " and " + b + " is " + product; return array; } // Here is the test for multiply(); uncomment it to run it -testMultiply(5,9); +// testMultiply(5,9); // Once you get the test passing, do an a-c-p cycle and synchronize the code between GitHub and your laptop. Don't forget to create a new branch for your work on the next question! @@ -69,14 +70,12 @@ function sumAndMultiply(a, b, c) { var abmul = multiply(a, b); abmul = multiply(abmul[0], c); array[1] = abmul[0]; - array[2] = a + " and " + b + " and " + c + " sum to " + array[0] +"."; - array[3] = "The product of " + a + " and " + b + " and " + c + " is " + array[1] + "."; - - return array; + array[2] = "The sum of " + a + ", " + b + " and " + c + " is " + array +"."; + array[3] = "The product of " + a + ", " + b + " and " + c + " is " + array[1] + "."; } // Here is the test for sumAndMultiply(); uncomment it to run it -testSumAndMultiply(4,7,5); +// testSumAndMultiply(4,7,5); // Once you get the test passing, do an a-c-p cycle and synchronize the code between GitHub and your laptop. Don't forget to create a new branch for your work on the next question! @@ -106,7 +105,7 @@ function sumArray(sumArr) { // Here is the test for sumArray(); uncomment it to run it -testSumArray([2, 3, 4]); +// testSumArray([2, 3, 4]); // Once you get the test passing, do an a-c-p cycle and synchronize the code between GitHub and your laptop. Don't forget to create a new branch for your work on the next question! From dfd183e24958a8f0f0259759fc82cb3628f74a9e Mon Sep 17 00:00:00 2001 From: JohnMV13 Date: Tue, 19 Jun 2018 20:56:00 -0500 Subject: [PATCH 6/7] Fixed Problem 4 --- app.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/app.js b/app.js index 6a65e40..115441f 100644 --- a/app.js +++ b/app.js @@ -91,14 +91,13 @@ Test this function by hand in the console to get it working, and when you think // Write your code here function sumArray(sumArr) { - var sSum = 0 - for(var i = 0; i < sumArr.length; i++) { - var sSum= sum(sumArr[i], sSum)[0]; - - console.log(sSum) - + var sSum = []; + sSum[0] = sum(sumArr[0], sumArr[1])[0]; + var i = 2; + while (i<(sumArr.length)){ + sSum[0] = sum(sSum[0], sumArr[i])[0]; + i++; } - var array = [sumArr] array = sumArr + ' was passed in as an array of numbers, and ' + sSum + ' is their sum.'; return array; } From 14a54bfed113e22b19a19e9e05c9962489aecea4 Mon Sep 17 00:00:00 2001 From: JohnMV13 Date: Tue, 19 Jun 2018 21:03:36 -0500 Subject: [PATCH 7/7] actually fixed now --- app.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app.js b/app.js index 115441f..93d8b01 100644 --- a/app.js +++ b/app.js @@ -98,8 +98,8 @@ function sumArray(sumArr) { sSum[0] = sum(sSum[0], sumArr[i])[0]; i++; } - array = sumArr + ' was passed in as an array of numbers, and ' + sSum + ' is their sum.'; - return array; + sSum = sumArr + ' was passed in as an array of numbers, and ' + sSum + ' is their sum.'; + return sSum; } // Here is the test for sumArray(); uncomment it to run it