Question

* Create a function that takes in the length of two sides of a triangle and...

* Create a function that takes in the length of two sides of a triangle and returns an array of all integers that could be the length of the third side.
* Note: The sum of two sides of a triangle is always greater than the third.
*/

exports.default = (firstSide, secondSide) => {
// Your code goes here.
};

const triangleSideRanges = require('./question').default;

console.log(triangleSideRanges(3, 4)); // Expected Output:[ 2, 3, 4, 5, 6 ]

console.log(triangleSideRanges(11, 7)); // Expected Output:[5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]

console.log(triangleSideRanges(5, 18)); // Expected Output:[14, 15, 16, 17, 18, 19, 20, 21, 22]

console.log(triangleSideRanges(23, 4)); // Expected Output:[20, 21, 22, 23, 24, 25, 26]

URGENT PLEASE HELP!

Homework Answers

Answer #1

Solution:

var ans = [];
    var diff;
    if(firstSide > secondSide) {
        diff = firstSide-secondSide;
    }
    else {
        diff = secondSide-firstSide;
    }
    var i;
    for(i=diff+1;i<(firstSide+secondSide);i++) {
        ans.push(i);
    }
        return ans;

According to your question requirements javascript for fuction that takes in the lengths of two sides of triangle and return array of all integers that could be the length of third side.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
A manufacturing company is purchasing metal pipes of standard length from two different suppliers, ABC and...
A manufacturing company is purchasing metal pipes of standard length from two different suppliers, ABC and XYZ. In the past two months there are increasing complaints by the Production Manager that delivery times by ABC present higher variability in comparison to the delivery times by XYZ. The Production Manager is worried that this variability will make it harder to efficiently schedule the production process. If the variance of XYZ remains unchanged, what should be the variance of ABC in order...
Assuming that the population standard deviation is unknown, calculate the 95% confidence interval of the population...
Assuming that the population standard deviation is unknown, calculate the 95% confidence interval of the population mean. The following is the data. Calculating Process should be shown by Excel (Formulas). What formulas in statistics are used? 7 21 23 24 18 16 2 19 11 6 3 13 17 9 5 12 13 17 4 14 15 25 12 24 22 14 14 20 15 11 26 17 21 11 4 13 16 14 13 14 25 23 9 15...
6. Using the class data (see Blackboard file - "Class Survey Data - PSS-10 and GAS")...
6. Using the class data (see Blackboard file - "Class Survey Data - PSS-10 and GAS") calculate the correlation between the GAS – Goal disengagement and the GAS – Goal reengagement scores. Write the results in a statistical statement. 7. Using the class data calculate the correlation between the GAS – Goal disengagement and the PSS-10 scores. Write the results in a statistical statement. 8. Using the class data calculate the correlation between the GAS – Goal reengagement scores and...
A manufacturing company is purchasing metal pipes of standard length from two different suppliers, ABC and...
A manufacturing company is purchasing metal pipes of standard length from two different suppliers, ABC and XYZ. In the past two months there are increasing complaints by the Production Manager that delivery times by ABC present higher variability in comparison to the delivery times by XYZ. The Production Manager is worried that this variability will make it harder to efficiently schedule the production process. Does the sample data indicate a statistically significant difference at the 5% level? Justify your answer....
A manufacturing company is purchasing metal pipes of standard length from two different suppliers, ABC and...
A manufacturing company is purchasing metal pipes of standard length from two different suppliers, ABC and XYZ. In the past two months there are increasing complaints by the Production Manager that delivery times by ABC present higher variability in comparison to the delivery times by XYZ. The Production Manager is worried that this variability will make it harder to efficiently schedule the production process. Does the sample data indicate a statistically significant difference at the 5% level? Justify your answer....
Part A. In the past it has been found that the arrival time have a population...
Part A. In the past it has been found that the arrival time have a population mean value of μ = 13 and a population standard deviation of σ = 6.26. Using the given data, test whether this mean has changed. Use the critical value approach to test the hypothesis. The significance level alpha is set at 0.05 . The original data of time taken is given below. Show the process by using excel (Formulas). Part B. Test the hypothesis...
PLEASE CODE EVERYTHING IN C++ Quick Thinking: Arrays Objective: Test your knowledge in providing efficient solutions...
PLEASE CODE EVERYTHING IN C++ Quick Thinking: Arrays Objective: Test your knowledge in providing efficient solutions for operations on arrays. What you can use only: Loops These variables only const int SIZE = 4; int variable = 0, master array [SIZE][SIZE]; double average = 0.0, parallel array [SIZE]; One conditional statement per problem if needed Note: the conditional statement cannot contain an “else” or “else if’ Provide solutions to the following problem. Absolutely no hard coding can be used. ----------------------------------------------------------------------------------------------------------------------------------------------------------...
Create a function that takes two numbers as arguments (num, length) and returns an array of...
Create a function that takes two numbers as arguments (num, length) and returns an array of multiples of num up to length. Examples: arrayOfMultiples(7, 5) ➞ [7, 14, 21, 28, 35] arrayOfMultiples(12, 10) ➞ [12, 24, 36, 48, 60, 72, 84, 96, 108, 120] arrayOfMultiples(17, 6) ➞ [17, 34, 51, 68, 85, 102] Notes Notice that num is also included in the returned array. Write in C++ language ..
____________________________________________ The results of a sample of 372 subscribers to Wired magazine shows the time spent...
____________________________________________ The results of a sample of 372 subscribers to Wired magazine shows the time spent using the Internet during the week. Previous surveys have revealed that the population standard deviation is 10.95 hours. The sample data can be found in the Excel test data file. What is the probability that another sample of 372 subscribers spends less than 19.00 hours per week using the Internet? ____________________________________________ Develop a 95% confidence interval for the population mean ____________________________________________ If the editors...
A consumer advocate researches the length of life between two brands of refrigerators, Brand A and...
A consumer advocate researches the length of life between two brands of refrigerators, Brand A and Brand B. He collects data (measured in years) on the longevity of 40 refrigerators for Brand A and repeats the sampling for Brand B. These data are measured in years. (You may find it useful to reference the appropriate table: z table or t table) Brand A Brand B Brand A Brand B 23 12 21 18 22 15 17 20 18 20 20...