Created
March 9, 2017 05:04
-
-
Save kyleturman/94ceafe373671d9554f1633092adb7a7 to your computer and use it in GitHub Desktop.
Exported from Popcode. Click to import: https://popcode.org/?gist=94ceafe373671d9554f1633092adb7a7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Number types</title> | |
</head> | |
<body> | |
<h1>Enter a number and I'll tell you what it is!</h1> | |
<input id="number" placeholder="Enter a number" /> | |
<button id="number-button">Check number</button> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"enabledLibraries":["jquery"]} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function checkNumber(number_string){ | |
// Check the console to see what type | |
// this variable is! | |
console.log(number_string + " is a " + typeof(number_string)); | |
// The `parseInt` function turns the | |
// string into a number | |
var number = parseInt(number_string); | |
// Check the console to see what type | |
// of variable this is! | |
console.log(number + " is a " + typeof(number)); | |
if (number === 1) { | |
alert('This number is one!'); | |
} | |
if (number === 2) { | |
alert('This number is two!'); | |
} | |
// START HERE | |
// Finish the if statements and go all the way to 10! | |
// ... | |
} | |
$(document).ready(function() { | |
$("#number-button").on("click", function(){ | |
var string_value = $('#number').val(); | |
checkNumber(string_value); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment