You are here: Home / Topics / Convert Minutes into Seconds in JavaScript

Convert Minutes into Seconds in JavaScript

Filed under: JavaScript on 2023-08-06 20:35:41

Write a function that takes an integer minutes and converts it to seconds.

Examples:

convert(5) ➞ 300

convert(3) ➞ 180

convert(2) ➞ 120

 

Code

<script>

function convert(minutes){

return minutes * 60;  //1 minutes equals to 60 seconds.

}

convert(5) // output 300

convert(3) // output 180

convert(2) //output 120

 

</script>


About Author:
M
Mr. Dubey     View Profile
Founder of MCQ Buddy. I just like to help others. This portal helps students in getting study material free. Share your stuff here so that others can get benefitted.