These are chat archives for **Codewars/codewars.com/kata-solving-help**

Hi, is there a way to return a value from a function and do something else anyone? (EG)

`return a( && hours = 0 ;)`

What do you mean something else mm

?

Can I then set a variable to 0 for example?

EG

`return a ( THEN DO SOMETHING HERE )`

I mean, would

```
{
DO SOMETHING HERE
return a;
}
```

not be sufficient?

and why so?

what scenario are you thinking of

a return litterally places you back to a caller which continues its code until it's done, meaning there would literally be no time to execute the "THEN DO SOMETHING" from the original return

hI

Thanks for the answer

No it wouldnt work for my solution

Let me show you why

In my solution, if I set the hours as 0, then when I return it, I will have the wrong answer

So i need to return it (so its right) then set the hours as 0

```function timeConvert(num) {

var hours;

if (num < 0) { var hours = 0; return "00:00"; }

if (num > 60) {

hours = hours + 1;

return timeConvert(num - 60);

}

if (hours < 10 && num < 10) {

return "0" + hours + ":" + "0" + num;

}

if (hours < 10 ) {

return "0" + hours + ":" + num;

}

else {

return hours + ":" + num;

}

}

```

```
function timeConvert(num) {
var hours;
if (num < 0) { var hours = 0; return "00:00"; }
if (num > 60) {
hours = hours + 1;
return timeConvert(num - 60);
}
if (hours < 10 && num < 10) {
return "0" + hours + ":" + "0" + num;
}
if (hours < 10 ) {
return "0" + hours + ":" + num;
}
else {
return hours + ":" + num;
}
}
```

I don't think its wise to tackle that kata that way

in the description itself, they point you towards a nice little hint called modulo

the point of the kata is to learn how to use that

Yeah if you use the modulo your solution will be much cleaner, and probably less if/else statements.

lets say you have 200 minutes.

200 minutes has 3 hours (180 minutes) and 20 minutes rest

so the answer for the clock would then just be 3:20

200 / 60 = 3. (you'll have to fix JS double result)

200 % 60 = 20 (whatever is over when you have fit 60, 3 times in 200)

200 minutes has 3 hours (180 minutes) and 20 minutes rest

so the answer for the clock would then just be 3:20

200 / 60 = 3. (you'll have to fix JS double result)

200 % 60 = 20 (whatever is over when you have fit 60, 3 times in 200)

sounds about right, find the hours, then find the minutes. One note, you can do Math.floor(200 / 60) to get 3. It is known as integer division or floor division.

Aww I wanted to keep that in as something he should find out :P

dang it, well I just helped since his algorithm seem OK aside from that.

he still has to code it anyways :smile: