Facing issue in a simple code of JS document.getElementById object

While I am trying to access document object through vs code, it is showing Null. However, while trying to access the same object through Web browser console, it is working perfectly fine.

// this is html part

first
Second
third
fourth

// This is JS part

let abx= document.getElementById(‘sec’);
console.log(abx);