0

Macbook, OSX 10.9 VsCode - Enterprise 2019

// Issue Description

I have a very simple JS function


function countup(n) {
    if (n < 1) {
      return [];
    } else {
      const countArray = countup(n - 1);
      //debugger;
      countArray.push(n);
      return countArray;
    }
  }
  console.log(countup(5));

What I need help with?

Run this with a debugger on vscode by adding breakpoints in between. When I try to use the launch.json config


{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "chrome",
            "request": "launch",
            "name": "Launch Chrome",
            "file": "${workspaceRoot}/Test.js"
        }
    ]
} 

This basically renders the JS file in Chrome but does not execute the actual function. I have tried the same with a local server + chrome debugger extension in vs code.

How do I get this to work?

0

1 Answer 1

1

to run the JS code, you need to open a new HTML file and run the code in the HTML. if it is just a basic code you can use the Script tag <script> and call the function in the body tag using the onload Event. after you do that you can use the chrome debugger (press F12)

here an example

<body onload="Myfunction()">
    <script>
        function Myfunction() {
        console.log('hello world');
        }
    </script>
</body>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.