I'm creating a JS counter for an exams website, I found that they can add extra time very easily in console by running sec += 10000
, how can I stop this.
I'm using laravel in the backend
runCounter();
function runCounter() {
let min = 45;
let sec = min * 60;
let x = setInterval(function() {
console.log(secFormat(sec))
sec -= 1;
if (sec <= 0) {
endExam();
clearInterval(x);
}
}, 1000);
}
function secFormat(x) {
x = Number(x);
let h = Math.floor(x / 3600);
let m = Math.floor(x % 3600 / 60);
let s = Math.floor(x % 3600 % 60);
m += h * 60;
if (m < 10) {
m = "0" + m
}
if (s < 10) {
s = "0" + s
}
return m + ":" + s;
}
function endExam() {
alert('exma ended');
}