function show() {
let date_ = new Date();
let sec = String(date_.getSeconds());
fill_gaps(sec);
function fill_gaps(candidate) {
if (candidate.length < 2) {
candidate = "0" + candidate;
} else {
candidate = candidate;
}
}
time_ = String(`${sec}`);
console.log(time_)
}
The fill_gaps()
function is supposed to change the var sec value; but it isn't changing the value outside the function. My guess is that it is not changing on global scope.
I know this is a basic problem but I can't figure it out as I am still a beginer.
Expected:
console.log(time_) = 0("and the current second")
Actual:
console.log(tiem_) = ("the current second")