12 pts
Create a function that takes two numbers, (num1) and (num2), and returns an array that will contain four values. First, divide the two numbers (num1)/(num2) to get the quotient. Split the resulting quotient into 2 integers and then get their product. Split the resulting product into individual integers and add them to get their sum. Split the resulting sum into 2 integers and get their difference (first number) - (second number). The array that will be returned will be in the following format: [quotient, product, sum, difference]. If any of the calculations result in only one digit, use 0 as the first digit. Ex. arithmetic(36, 3): 36/3 = 12; 1*2 = 2; 0+2 = 2; 0-2 = -2; Result would be [ 12, 2, 2, -2 ]. You can assume the first number (num1) will be greater than the second number (num2) and that both numbers will be greater than zero.
function arithmetic(num1, num2){
//Enter your code below
}
function arithmetic(num1, num2){
//Enter your code below
}
Test Cases:
-
arithmetic(185, 5) to return [37,21,3,-3]
-
arithmetic(267, 3) to return [89,72,9,-9]
-
arithmetic(174, 2) to return [87,56,11,0]