I'm trying to use conditional breakpoint like 'lessThan5' is executed if n is 3 and 'greaterThan5' is executed if n is 10.
(Please excuse this so simple example. It was just made for asking question to solve other problem)
function lessThan5(n){
console.log('less than 5');
}
function greaterThan5(n){
console.log('greater than 5');
}
function checkNum(n){
if(n < 5 ){
lessThan5();
} else {
greaterThan5();
}
}
checkNum(n);
I tried 'Add breakpoint' in VScode at checkNum(n) and change n to 3 with 'Expression in Edit breakpoint'. But I got 'ReferenceError: n is not defined'. I guess I've searched almost everything about editting breakpoint but it didn't work.
Is there any possible way to insert conditional input in VS code debug mode?
It isn't clear to me exactly what you are trying to do, but here is how you could set a conditional breakpoint at
checkNum(n):Then you call
checkNum(<someValue>)likecheckNum(11)and the debugger will stop at your conditional breakpoint since(n < 5) || (n > 10)returnstrue.