function stopWatch() {
let startTime = Date.now();
function getDelay() {
let elapsedTime = Date.now() — startTime;
alert(elapsedTime);
}
return getDelay;
}
let timer = stopWatch();
for (let i = 0; i < 1000000; i++) {
let foo = Math.random() * 10000;
}
timer();
function stopWatch() {
let startTime = new Date();
function getDelay() {
let elapsedTime = new Date() - startTime;
alert(elapsedTime);
}
return getDelay;
}
let timer = stopWatch();
for (let i = 0; i < 1000000; i++) {
let foo = Math.random() * 10000;
}
timer();
Thanks! In VS Code, when you have (for example) an incorrect character, you’ll see the warnings appear in your code editor as a squiggly underline or in the console when you click on the Warning/Error icons in the bottom left corner of the window:
Also if your using VS Code you can reformat the document by selecting Format Document from the context menu. This will do all the nice indenting for your code…I had problems reading this at first coz the formatting was really throwing me off.
Creating engaging and entertaining content for designers and developers since 1998.