How to debug JavaScript code on Chrome browser and Vs code?

I just want to debug this code :

var x = 1;
a();
b();
console.log(x);

function a()
{
  var x = 10;
  console.log(x);
}

function b()
{
    var x = 100;
    console.log(x);
}

I simply made an index.js file and want to debug the code line by line? Then how to connect with the chrome dev tools?


It also gives me “Debug with Js terminal” option which I am not getting how to do.

If you look at the top-left of the screen, there’s a ‘Launch Chrome…’ button. Clicking that should do what you need, and you’d be able to set breakpoints, read variable values and so on, as you step through the code.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.