skip to Main Content

I have a pretty simple function that I want to test but I’m not sure how to see the output. Do I need to create an HTML file and open it in a browser to see the result in the console? Or is there a way to see the console log directly in VS Code?

const myArray = [1,4,6,8,9,10,11,13];

findIndexOfNumber(myArray, 10);

function findIndexOfNumber(arr, target) {
    console.log(arr.indexOf(target))
    return arr.indexOf(target)
}

I wrote this up in a JS file. I understand I can just make an HTML file and link the two but I want to know if there is a quicker way to just see the results in VS Code from just the JS file alone.

2

Answers


  1. Take a look at this post: https://superuser.com/questions/946244/is-there-a-way-to-run-javascript-without-a-browser-like-a-shell-or-batch-script. You can use something like node js to run javascript without a browser

    Login or Signup to reply.
  2. Yes you see in the output also.
    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search