Need help putting JavaScript response in my webpage

currently working on a project that uses all my overall skills in Html, Css, and JavaScript. At the moment my JavaScript asks the user 2 questions, then takes the answers from those 2 question and gives a interactive response using functions, conditional statements, and string interpolation. My question is how can I put that response in my web page instead of giving another alert() with the response?

here is my code below:
Html


Css

JavaScript

1 Like

the simplest function is document write:

personally, i would go for something a little more sophisticated like using getElementById and then use appendChild to add to this element.

or you could use jquery, which simplify this process. Given the DOM manipulation seems quite small, react and vue would be overkill

3 Likes

document.write() definitely Works, but how can I specify where to put the interactive JavaScript response it in my html? like if I want to put it in a certain h1 tag? and can I style that response using Css?

then use getElementById and appendChild, you can google to find documentation about these methods (MDN is good)

1 Like

used document.write() and it worked. The problem that I had was that I didn’t have all the knowledge of the script tag. I might not have gotten to that lesson in codecademy yet. So before I would press document.write() in the JavaScript file and it would appear at an undesired place in my web page.

why do you think i said:

this implied document.write is not very sophisticated method.

I’m definitely gonna try to use getElementByld() and appendChild(). If I hit any roadblocks I’ll post back.

you might need textContent as well.