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

Convert Hours into Seconds in JavaScript

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

Write a function that converts hours into seconds.
 

Examples:

howManySeconds(2) ➞ 7200

howManySeconds(10) ➞ 36000

howManySeconds(24) ➞ 86400

Notes:

   60 seconds in a minute, 60 minutes in an hour

 

<script>

function howManySeconds(hour){

var seconds = hour * 60 * 60 *;

}

 

var hour = 2;

console.log(howManySeconds(hour)); /// this will print 7200 in console.

 

</script>

About Author:
S
Shyam Dubey     View Profile
If you are good in any field. Just share your knowledge with others.