Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added comments to make the code easier to read #72

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions js/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
// Generates a random number between the min and max value
function getrandomnumber(min,max) {
return Math.floor(Math.random()*(max-min+1)+min);
}

$(document).ready(function () {
$('#tsfd').hide();

let rand = getrandomnumber(1,100);

let guesspanel = $('#guesspanel');
Expand Down Expand Up @@ -37,6 +39,8 @@ $(document).ready(function () {
diffbox.change(function () {
let diff = $('input[name=radio]:checked').val();
// $('#resetbtn').click();

// Generates a random number based on the difficulty level
switch (diff){
case '0':
rand = getrandomnumber(1,10);
Expand Down Expand Up @@ -87,6 +91,7 @@ $(document).ready(function () {
$('#diffchoose').hide();
count++;

// gives feedback on the hint such as: too high, too low
if(gval<rand){
toohigh = false;
toolow = true;
Expand Down Expand Up @@ -121,6 +126,7 @@ $(document).ready(function () {
let r2 = Math.floor(Math.random()*randstr.length);
cdig = randstr[r2];

// generates hints
let div2,div3,div5,product,condigit;
if(rand%2==0){
div2="The number is even.";
Expand Down