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:
S
Shyam Dubey     View Profile
If you are good in any field. Just share your knowledge with others.