The reason why hulk
is undefined when you write:
let hulk = console.log("have a great day");
…is because you’re assigning it the return value of console.log("have a great day")
. Because console.log
doesn’t return anything, hulk
gets assigned the value undefined
. You can’t assign it a string value and do a console log all in one statement. Rather, you can do something like this instead:
let hulk = "have a great day";
console.log(hulk);
solved why cannot i write console.log in a primary function