Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Q5 #35

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Q5 #35

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 48 additions & 5 deletions js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ Test this function by hand in the console to get it working, and when you think

// Write your code here
function sum(a, b) { //eslint-disable-line

let sum = a + b;
return[sum,`The sum of ${4} and ${7} is ${11}.`];
}

// Here is the test for sum(); uncomment it to run it
Expand All @@ -21,13 +22,15 @@ function sum(a, b) { //eslint-disable-line
/* Problem 2
Write a function called multiply() that takes in two numbers as arguments and returns an array where the first element is the product of those numbers, and the second element is a string that EXACTLY follows this example and uses the values that were input into the function:

"The product of 5 and 9 is 45."
""

Test this function by hand in the console to get it working, and when you think it is finished, uncomment the call for the testMultiply() function and see if the test passes.*/

// Write your code here
function multiply(a, b) { //eslint-disable-line

function multiply(a, b) {
//eslint-disable-line
let product = a * b
return[product,`The product of ${5} and ${9} is ${45}.`]
}

// Here is the test for multiply(); uncomment it to run it
Expand All @@ -48,6 +51,22 @@ Test this function by hand in the console to get it working, and when you think

// Write your code here
function sumAndMultiply(a, b, c) { //eslint-disable-line
let sum = (a,b)[0];
var sum2 = (sum, c)[0];

let product = multiply (a,b)[0];
let pruduct2 = multiply (product, c)[0];

var str3A = a + ' and ' + b + ' and ' + c + ' sum to ' + sum2 + '.';
var str3B = 'The product of' + a + 'and' + b + ' and ' + c + 'is' + product2 + '.';
var arr3=[];
arr3[0]= sum2;
arr3[1]= product2;
arr3[2] = str3A;
arr3[3] = str3B;
return arr3;



}

Expand All @@ -68,9 +87,21 @@ Test this function by hand in the console to get it working, and when you think

// Write your code here
let testArray = [2, 3, 4]; //eslint-disable-line
function sumArray(testArray)


function sumArray(sumArr) { //eslint-disable-line

function sumArray(sumArr) {
sumArray(testArray)[1] ===
var sum4_1 = sum (testArray[0] , testArray[1] )[0] ;
var sum4_2 = sum (sum4_1 , testArray[2] )[0] ;

var str4 = testArray + " was passed in as an array of numbers, and " + sum4_2 + " is their sum." ;

var arr4=[] ;
arr4[0] = sum4_2;
arr4[1] = str4;
return arr4;
}

// Here is the test for sumArray(); uncomment it to run it
Expand All @@ -91,6 +122,18 @@ Test this function by hand in the console to get it working, and when you think

// Write your code here
function multiplyArray(multArr) { //eslint-disable-line
var testArray = [2 , 3 , 4] ;

var product5_1 = multiply(testArray[0] , testArray[1])[0];
var product5_2 = multiply(product5_1 , testArray[2])[0];

var str5 = "The numbers " + testArray + " have a product of " + product5_2 + ".";

var arr5b=[] ;
arr5b [0] = product5_2;
arr5b [1] = str5;

return arr5b;

}

Expand Down