Quote generator question

I’m really new to all this but I don’t understand how I put the “output” from the function in the html text.
Here’s a link to what I’ve done this far
https://codepen.io/tindrutt/pen/KKPOKQp

You need to call a function (that you have yet to create) which will return a quote and assign to the innerHTML property of document.getElementByID('text'). Currently, you are assigning the string “myFunction” to it when the page loads.

Take all the code above that line and put it into a function and then call the function.

let arrayQuote

but you use

arrayQuotes[Math.floor(Math.random() * arrayQuotes.length)]

and

getElementByID

is wrong

getElementById

is right.

i’m probably an idiot but i still cant figure it out, it feels like i’ve tried everything.
https://codepen.io/tindrutt/pen/vYBopBv

In the last step you have to call the function. Just like this:

myFunction(newQuote);

i think i’ve done that? or do you mean in the html? i’m so confused lool

In JS. But have some other errors too. :frowning:

document.getElementById(’#text’).innerHTML

Do not use the # . Just simple

document.getElementById(‘text’).innerHTML

oh thank you but isn’t this right?
myFunction(newQuote) { document.getElementById('text').innerHTML = quote; }
or how do you mean with the function?

function myFunction(newQuote) { document.getElementById(‘text’).innerHTML = newQuote ;
}
myFunction(newQuote);

The last line / var quote = … / is not necessary.

OMG ITS WORKING thank you sm i’ve been trying this the last two days omgg wow thank you

1 Like

:slight_smile: You’re welcome. Calm down and keep going, you are on good way.

1 Like