Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 2 of 2
  1. #1
    Dee
    Dee is offline
    Junior Member
    Join Date
    Jun 2017
    Posts
    1
    Member #
    56815

    Cant seem to figure out how to do the following

    Id like the following program to be able to:
    - Deselect numbers
    - Allow user to guess the same set of numbers, multiple times
    - Show the history of guesses
    - An alert for good guess.

    https://codepen.io/anon/pen/mwraaR

  2.  

  3. #2
    Senior Member Ronald Roe's Avatar
    Join Date
    Mar 2011
    Location
    Oklahoma City
    Posts
    3,141
    Member #
    27197
    Liked
    959 times
    To toggle the button, add and remove a class using classList.add() and classList.remove(). You'll use classList.contains() to determine whether the to add or remove the class. That'll toggle the styles. You can use array.indexOf() to find a number in the array, and array.splice() to remove it.

    Not entirely sure what your second point is asking for.

    Showing the history of guesses can be done by storing them in a multidimensional array. You'll use array.push() to add an array to the last position of the parent array. [[1, 3, 5], [5, 6, 7]] <= new array gets "pushed" into the bottom. Then, use a nested for loop to output.
    Ron Roe
    Web Developer
    "If every app were designed using the same design template, oh wait...Bootstrap."


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Tags for this Thread

All times are GMT -6. The time now is 06:59 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com