Skip to content

derekjpeters/For-While-Loops

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

For While Loops Script

Overview

This HTML file named For While Loops includes a script designed to demonstrate various array operations, the usage of control structures like loops and conditionals, and the process of handling user inputs through prompts. It provides practical examples of manipulating arrays, employing for and while loops, and implementing simple interactive predictions based on user input.

Features

1. Array Manipulation

  • Demonstrates how to find the index of an element, move elements within an array, and remove elements from an array.

2. Loop Operations

  • For Loop: Implements a for loop to count from 1 to 10, appending "Mississippi" to each number.
  • Even Number Logger: Utilizes a for loop to iterate through an array of numbers, logging only the even numbers to the console.
  • Sum Odd Numbers: A while loop is used to sum odd numbers from 1 to 10.

3. User Interaction

  • Predictions: Collects user predictions for game winners and their scores through browser prompts.
  • Results Comparison: Compares user predictions against simulated results to calculate and display the user's accuracy in predictions.

Technical Details

  • Language: HTML & JavaScript
  • External Libraries: None required.
  • Browser Compatibility: Compatible with modern web browsers. Outputs are logged to the console, and inputs are collected via prompts.

Instructions

Opening the File

  • Open the HTML file in a web browser to execute the script.

User Input

  • When prompted, enter your predictions for the winners of the games and their scores. This input phase will occur twice, corresponding to two hypothetical matchups.

Viewing Results

  • The script logs operations performed on arrays, iterations of loops, and the comparison of user predictions against simulated outcomes. Check the console of your web browser to view these logs.

Notes

  • The outcomes of the games are simulated randomly within the script, and the user's score is calculated based on these simulations.
  • The script uses the prompt function to collect user input, which may be blocked or require permission in some browser settings.
  • For full interaction with the prompts and to view console outputs, ensure your browser's JavaScript console is accessible.

Use Case

This script is primarily for educational purposes, designed to illustrate JavaScript programming concepts such as array manipulation, control structures (loops and conditionals), and basic user interaction through the web browser. It is suitable for learners looking to explore these concepts in a practical, hands-on manner.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published