You get undefined in several situations:
let x // Declared but not assigned
console.log(x) // undefined
function noReturn() {}
console.log(noReturn()) // undefined (no return)
let obj = {}
console.log(obj.missing) // undefined (no property)
If you see unexpected undefined values, check that you're assigning values and accessing properties that exist.