JavaScript Treehouse Club - MASH MASH - JavaScript The Structure of Functions - Part 3 of 3

Megan MacDonald
PRO
Megan MacDonald
Pro Student 1,570 Points

I cannot find which set of parentheses to write in, or what I'm supposed to write in the parentheses in this code.

I'm definitely stuck here.

script.js
function random_age(age) {
  Math.floor(Math.random(num) num * age);
}
random_age(age);
index.html
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Futuristic MASH</title>
    <link href="normalize.css" rel="stylesheet">
    <link href="style.css" rel="stylesheet">
  </head>
  <body>
    <h1 class="logo"><img src="img/mash-logo.svg" /></h1>
    <p class="instructions">Fill in the blanks and your future will be foretold.</p>
    <form action="" method="post" id="mash">
      <div class="choice-bucket">
        <h4 class="highlight">What's your future pet?</h4>
        <input name="pet[]">
        <input name="pet[]">
        <input name="pet[]">
        <input name="pet[]">
      </div>
      <input type="submit" value="Tell my fortune">
    </form>

    <script src="script.js"></script>

  </body>
</html>

1 Answer

Zachary Kaufman
Zachary Kaufman
1,462 Points

When you are describing the function (line 1) you give the argument (thing inside the parenthesis) a variable name such as "age". When you are calling the function (line 4) is when you give the variable a value (such as 5 or 7 or 25). Calling the function is usually when the user will give the input, the function itself it written by you to describe what the input must be. Does that make sense?

Megan MacDonald
Megan MacDonald
Pro Student 1,570 Points

I think so. The instruction for the challenge are "Call the function by giving an age in the space for a parameter." As far as I can tell the first line already has a parameter (age) in the parentheses. I thought that I needed to add an actual number to the last set of parentheses (like 15) but so far that bounces back at me as incorrect. Perhaps I'm misunderstanding the instruction?

Megan MacDonald
Megan MacDonald
Pro Student 1,570 Points

Nevermind- that worked! I think I was entering it into the second line rather than the fourth. Thanks for your help!