Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 1100671 of Silly story generator

  • Revision slug: Learn/JavaScript/First_steps/Silly_story_generator
  • Revision title: Silly story generator
  • Revision id: 1100671
  • Created:
  • Creator: chrisdavidmills
  • Is current revision? No
  • Comment

Revision Content

{{draft}}{{PreviousMenu("Learn/JavaScript/First_steps/Arrays", "Learn/JavaScript/First_steps")}}

You've covered a lot in this module, so it must feel good to have reached the end! The final step before you move on is to attempt the assessment for the module — this involves a number of related exercises that must be completed in order to create the final design — a business card/gamer card/social media profile.

Prerequisites: Before attempting this assessment you should have already worked through all the articles in this module.
Objective: To test comprehension of JavaScript fundamentals, such as variables, numbers, operators, strings, and arrays.

Starting point

To get this assessment started, you should:

  • Go and grab the...

Note: Alternatively, you could use a site like JSBin or Thimble to do your assessment. You could paste the HTML and fill in the CSS into one of these online editors. If the online editor you are using doesn't have a separate JavaScript panel, feel free to put it inlin a <script> element.

Project brief

You have been provided with some raw HTML/CSS and a few text strings and JavaScript functions; you need and need to write the necessary JavaScript to turn this into a working program, which does the following:

  • Generates a silly story when the "Generate random story" button is pressed.
  • Replaces the default name "Bob" in the story with a custom name, only if a custom name is entered into the "Enter custom name" text field before the generate button is pressed.
  • Converts the default US weight and temperature quantities and units in the story into UK equivalents if the UK radio button is checked before the generate button is pressed.
  • Will generate another random silly story if you press the button again (and again...)

The following sections describe what you need to do.

Basic setup:

Hints and tips

  • You don't need to edit the HTML in any way, except to apply the JavaScript to your HTML.
  •  

Example

The following screenshot shows an example of what the finished program should output:

[INSERT IMAGE HERE]

 

Assessment

If you are following this assessment as part of an organized course, you should be able to give your work to your teacher/mentor for marking. If you are self-learning, then you can get the marking guide fairly easily by asking on the dev-mdc mailing list, or in the #mdn IRC channel on Mozilla IRC. Try the exercise first — there is nothing to be gained by cheating!

{{PreviousMenu("Learn/JavaScript/First_steps/Arrays", "Learn/JavaScript/First_steps")}}

Revision Source

<p>{{draft}}{{PreviousMenu("Learn/JavaScript/First_steps/Arrays", "Learn/JavaScript/First_steps")}}</p>

<p class="summary">You've covered a lot in this module, so it must feel good to have reached the end! The final step before you move on is to attempt the assessment for the module — this involves a number of related exercises that must be completed in order to create the final design — a business card/gamer card/social media profile.</p>

<table class="learn-box standard-table">
 <tbody>
  <tr>
   <th scope="row">Prerequisites:</th>
   <td>Before attempting this assessment you should have already worked through all the articles in this module.</td>
  </tr>
  <tr>
   <th scope="row">Objective:</th>
   <td>To test comprehension of JavaScript fundamentals, such as variables, numbers, operators, strings, and arrays.</td>
  </tr>
 </tbody>
</table>

<h2 id="Starting_point">Starting point</h2>

<p>To get this assessment started, you should:</p>

<ul>
 <li>Go and grab the...</li>
</ul>

<div class="note">
<p><strong>Note</strong>: Alternatively, you could use a site like&nbsp;<a class="external external-icon" href="https://jsbin.com/">JSBin</a> or <a class="external external-icon" href="https://thimble.mozilla.org/">Thimble</a> to do your assessment. You could paste the HTML and fill in the CSS into one of these online editors. If the online editor you are using doesn't have a separate JavaScript panel, feel free to put it inlin a <code>&lt;script&gt;</code> element.</p>
</div>

<h2 id="Project_brief">Project brief</h2>

<p>You have been provided with some raw HTML/CSS and a few text strings and JavaScript functions; you need and need to write the necessary JavaScript to turn this into a working program, which does the following:</p>

<ul>
 <li>Generates a silly story when the "Generate random story" button is pressed.</li>
 <li>Replaces the default name "Bob" in the story with a custom name, only if a custom name is entered into the "Enter custom name" text field before the generate button is pressed.</li>
 <li>Converts the default US weight and temperature quantities and units in the story into UK equivalents if the UK radio button is checked before the generate button is pressed.</li>
 <li>Will generate another random silly story if you press the button again (and again...)</li>
</ul>

<p>The following sections describe what you need to do.</p>

<p>Basic setup:</p>

<h2 id="Hints_and_tips">Hints and tips</h2>

<ul>
 <li>You don't need to edit the HTML in any way, except to apply the JavaScript to your HTML.</li>
 <li>&nbsp;</li>
</ul>

<h2 id="Example">Example</h2>

<p>The following screenshot shows an example of what the finished program should output:</p>

<p>[INSERT IMAGE HERE]</p>

<p>&nbsp;</p>

<h2 id="Assessment">Assessment</h2>

<p>If you are following this assessment as part of an organized course, you should be able to give your work to your teacher/mentor for marking. If you are self-learning, then you can get the marking guide fairly easily by asking on the <a href="https://lists.mozilla.org/listinfo/dev-mdc">dev-mdc</a> mailing list, or in the <a href="irc://irc.mozilla.org/mdn">#mdn</a> IRC channel on <a href="https://wiki.mozilla.org/IRC">Mozilla IRC</a>. Try the exercise first — there is nothing to be gained by cheating!</p>

<p>{{PreviousMenu("Learn/JavaScript/First_steps/Arrays", "Learn/JavaScript/First_steps")}}</p>
Revert to this revision