New course! Every coder should learn Generative AI!
Try a free lesson0
Help
I am a jss beginner.Q1 Why can't I use ${}. Q2 I can't change textContent(it is showing can't get the text of null)
4 Answers
0
1. We cannot access an html document before it is loaded. Wrap your JS code in window.onload function.
2. String literals are makred with `` , not with "".
See corrected code:
window.onload = function() {
let y=document.getElementById("a")
console.log(y.textContent)
let x=prompt()
console.log(`sjsjdjsj ${x}`)
}
+ 1
L
I
N
K
YOUR CODE.
0
Also, you are just logging to console and don't set any gtml content yet.