# Best 2015

812

8

1

Posted

## Introduction: Best 2015

Hi my name is Dasia WIlliams and this is my BEST project!!

In this link I have created a HTML file that shows the progression of my project.

## Step 1: Binary Search

I used a binary search to create my guessing game. A binary search has many uses, In the software developing world it can used to locate where a bug is in the execution of a program, It can be used to search through a pre-sorted array and it can also be used to access ordered data quickly when memory space is limited. For the purpose of this project I created a guessing game between the computer and my user.

picture taken from code.scottshipp.com

## Step 2: How My Guessing Game Works

I alert the user to let them know what numbers they should be guessing in-between. Then I prompt the user with the computer's guess which is determined using the equation in the picture above or a binary search. I then ask if the computer's guess is too high too low or correct. Within my code I take the user's input of H,C or L and make it uppercase so that I can define it in my while loop easier. After the user has entered their fist input the code enters a while loop that allows the computer to guess for a certain number of times.

## Step 3: Improvements

My code doesn't seem to work I noticed this problem and did not have enough time to fix it before the deadline. My Guess variable is the downfall in my code. It does not update so instead of progressively adding a smaller or larger number to the min or max variable based on the user input it continues to add 32, the original guess value, to the min or max variable. .this was how I attempted to fix this problem. We used .this for in a hackathon project I participated in. I understood how to use it for the most part but I received a lot of guidance from the volunteers that came to help the team that I was on. I would also make it so that when a user enters anything other than H,C or L in the prompt box that the users input is stored and enters the while loop when they when they enter the correct input. Other than actually making my code work I would have made my user interface more like a game and less like a series of prompts and alerts

Did you see my joke?

I used .this instead of this HAHAHAHA!!

## Step 4: I've Got 99 Problems and Coding Happens to Be One

In order for my code to work I had to use this equations

2^x = max 0=min ( within my code )

2^x-1=max 1=min ( the user sees)

At first I used the same numbers for the max and min variables in the front end and the back end. Then I used the "user sees" equation for the front end and the back end. After a whole week of looking things up on google I asked for some help and I found out that I had to use these equations in order for my code to work. In the picture above I am pointing at the back end version of the min and max variables.

## Step 5: Updating the Min and Max Variables

Getting the min and the max variables to update as the code loops through the while loop according to the user input was another problem that I came into. At first I used high guess and low guess, this mistake is shown in "sixth" in the progression of my project link. But to condense my code so that debugging would be easier I saw that updating the min and max variables would be somthing I needed to do. So to fix this problem the code updates the min and the max based on the users input of H,C or L.

## Step 6: For or While Loop??

Another problem that I came into is weather using a for loop or a while would make my code more efficient and effective. I knew that I needed to use a loop for my code but I didnt know what loop I needed to use. W3schools said that a " A for loop loops through a block of code a number of times" and that "A while loop loops through a block of code while a specified condition is true." A for loop would work because I knew haw many guess the computer would need using this equation

2^X=max guesses = x

and I could use a while loop because I had this information as well. The for loop and the while are very similar but I decided to use a while loop because it made my code simpler.

## Step 7: Oh //nonprotect Oh //nonprotect

Through out my project I worked on jsbin.com because this was the website that I was introduced to code on. There was one warning that would not allow my code to work at all and it was a warning about including //nonprotect in my code. But I couldn't figure out where to include //nonprotect in my code and why even needed it in my code. One of the computer science teachers explained to me that the warning is just the computer protecting it's self from an infinite loop and that I need to add it to the top of my code.

this picture was taken from www.taringa.net

## Step 8:

var goodbye = "See ya and thanks for judging my project!";

this picture was taken from plzrtpodcast.com

## Recommendations

• ### 3D CAM and CNC Class

336 Enrolled

• ### Science of Cooking

We have a be nice policy.