Question: a ) In lab 5 . js , write a function named sumEvery 5 th that accepts a nonnegative integer n and returns the sum

a) In lab5.js, write a function named sumEvery5th that accepts a nonnegative integer n and returns the sum of the integers divisible by 5 from 1 to n, including n itself. Use a for loop in your function to solve this problem.
b) Run the two tests shown below in the console to verify your function works properly.
// Tests
console.log(sumEvery5th(20)); // expect 50...5+10+15+20=50 console.log(sumEvery5th(0)); // expect 0
c) Create a lab5.html file in your L5 folder that has a textarea element. Add code in your JavaScript file to call the sumEvery5th function with an argument of 20 and display the value it returns in the textarea of the web page. Hint: this was done in the pirate translation application.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!