JavaScript JavaScript Basics Creating Reusable Code with Functions Review: Giving Information to Functions

Mark Reitz
Mark Reitz
692 Points

what did I do wrong here?

What did I do wrong with the bottom line to call the function?

function getRandom( upper ) { return Math.floor(Math.random() * upper) + 1; } console.log(getRandom(12));

Adam Beer
Adam Beer
11,267 Points

Code

Wrap your code with 3 backticks (```) on the line before and after. If you specify the language after the first set of backticks, that'll help us with syntax highlighting.

      ```html
      <p>This is code!</p>
      ```

3 Answers

Steven Parker
Steven Parker
171,120 Points

The instructions ask you to "call the function and pass the value 12 to it", but they don't say anything about using "console.log" and don't expect to see it in the answer.

Ivelina Ventsislavova Stoilova
Ivelina Ventsislavova Stoilova
4,841 Points

Hi! I put this code

'{ getRandom(12)}'

which apparently doesn't work. Can you advise?

Thanks!

Steven Parker
Steven Parker
171,120 Points

I'm guessing you don't actually type in those single quotes, that would make the entire thing a literal string.

But you also don't need the braces. In actual code, they wouldn't be a problem but the quiz isn't expecting the answer to have them.

And in future, start a fresh question instead of asking one as an "answer" to an old question. That way more students will see your question and get a chance to respond.