JavaScript: Compute the sum of the two given integers
JavaScript Basic: Exercise-39 with Solution
Sum Two Integers and Return Based on Range
Write a JavaScript program to compute the sum of the two given integers. If the sum is in the range 50..80 return 65 otherwise return 80.
This JavaScript program calculates the sum of two given integers. If the sum falls within the range of 50 to 80 (inclusive), it returns 65; otherwise, it returns 80.
Visual Presentation:

Sample Solution:
JavaScript Code:
Output:
65 80
Live Demo:
Flowchart:

ES6 Version:
For more Practice: Solve these Related Problems:
- Write a JavaScript program that sums two integers and returns a specific value based on whether the sum falls within a custom range.
- Write a JavaScript program that computes the sum of two numbers and conditionally returns 65 or 80 based on a dynamic range check.
- Write a JavaScript program that calculates the sum of two integers and uses a ternary operator to return one of two values depending on the sum's range.
Improve this sample solution and post your code through Disqus.
Previous: JavaScript program to check the total marks of a student in various examinations.Next: JavaScript program to check from two given integers if either one is 8 or their sum or difference is 8.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics