Nov 20, 2022

# Solution 1 :

If you don’t really care about accuracy you can use a function like this:

`const secs = x => Math.round(x/60)`

This however calculates 0 (mins) when you enter 29 (seconds). If you don’t like that search for a more sophisticated solution online.

# Problem :

How can I change my display so instead of calculating seconds it calculates the minutes because when I tried to do the remminuts it did not work and im not quite sure where i am going wrong.

Here is the code for the javascript:

``````const container = document.querySelector('.counter');
const buttonsDiv = document.querySelector('.buttons');
const secInput = document.getElementById('seconds');

var seconds;
var remseconds;
var minuts;
var toCount = false;

function toSubmit(){
display('start');
remove('seconds');
remove('ok');
seconds = Number(secInput.value);
counting();
}

function display(e){
document.getElementById(e).style.display = 'block';
}

function remove(e){
document.getElementById(e).style.display = 'none';
}

function check(stat){
if(stat.id == "start"){
display("stop");
remove("start");
toCount = true;
}
else if(stat.id == "stop"){
display("continue");
remove("stop");
toCount = false
}
else{
display("stop");
remove("continue");
toCount =true;
}
}

function count(){
if(seconds > 0){
if(toCount == true){
seconds--;
remseconds = seconds % 60;
minuts = Math.floor(seconds / 60);

if(minuts < 10){
minuts = "0" + minuts;
}

if(remseconds < 10){
remseconds = "0" + remseconds;
}

container.innerHTML = minuts + " : " + remseconds;
}
}
else{
container.innerHTML = "DONE!";
buttonsDiv.style.opacity = "0";
}
}

function counting(){
remseconds = seconds % 60;
minuts = Math.floor(seconds / 60);

if(remseconds < 10){
remseconds = "0" + remseconds;
}

container.innerHTML = minuts + " : " + remseconds;
setInterval(count, 1000);
}
``````

As you can see it’s calculating for the seconds, but when I tried minutes instead, I got no results from it so i am very stuck on what i might be doing wrong.

### Comment posted by minimal reproducible example

Can you include a

### Comment posted by Kruspe

You also defined ‘minuts’

### Comment posted by Tazza Bazza

What should i change it too?

### Comment posted by Tazza Bazza

But i want the user to input minutes not the seconds.

### Comment posted by tlt

Well then just multiply the user input value by 60. If this is out of your reach you should visit w3schools and understand the basics