Hi people. I’m working through the loops section and wanted to see if I could make my own function (I think I learn better this way).
I want to make a function that will simply time. For example, if you put in 120 seconds it will return 2 minutes.
This is the beginning of what I have:
let seconds = 0;
let minutes = 0;
let hours = 0;
let days = 0;
let weeks = 0;
let months = 0;
let years = 0;
function howManyMinutes(amountSeconds) {
let i = amountSeconds;
while (i > 60) {
i - 60;
minutes++;
if (i < 60) {
i = seconds;
return amountSeconds + ’ is equal to ’ + minutes + ’ minutes and ’ + seconds + ’ seconds.’;
}
}
}
console.log(howManyMinutes(120));
However, when I try to run this in Terminal it seems to keep running leading me to assume that I must have made an infinite loop somewhere, or otherwise just done something completely wrong. Any advice would be very loved!!