Today, while working on a coderbyte problem, I managed to solve it on my own without any outside help, and it felt fantastic. However, upon completion, I realized that I solved it without creating any functions. Rather, I kept referring back to a previous variable. This made me wonder, is it crucial to employ functions when solving a problem? From a broader perspective, what are the benefits of converting a solution like mine into a function (or multiple functions)?
The problem involved breaking down a number representing minutes into hours and minutes. The process I used should be relatively straightforward to understand.
var num = 400;
var hourdivide = ( num / 60 );
var digits = hourdivide.toString().split('');
var hour = digits[0]
var almost = 60 * digits[0]
var minutes = num - almost
console.log( "you have " + hour + " hours and " + minutes + " minutes left" )