Created
December 29, 2022 13:45
-
-
Save DevGW/d57a835d14679d81c9139276d88c99d7 to your computer and use it in GitHub Desktop.
Javascript :: debugging
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* To use debugger: | |
1. add the debugger keyword in your function is VSCode | |
2. invoke the function yourself */ | |
function onlyOdds(num) { | |
debugger; // debugger keyword here | |
let sum = 0; | |
for (let i = num; i >= 1; i--) { | |
if (i % 2 === 1) { | |
sum += i; | |
} | |
} | |
return sum; | |
} | |
onlyOdds(3); // invoking the function ourselves here | |
/* Then, click the debugging option in VSCode | |
followed by the green debug arrow at the top-left of the screen. | |
Now, press down arrow dot to see your code run line by line (press red square to stop) */ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment