-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Akin C edited this page Oct 12, 2019
·
8 revisions
This repository is part of a larger project!
It seems that the logical operator or(||) in JS has functionalities which could be used in an interesting way.
An example follows:
function myFunction(optional)
{
var myDefaultValue = "I am the default";
var which = optional || myDefaultValue;
/*
Explanation:
Variable "which" will take the value "optional" if it is not false or
else the value of "myDefaultValue"
*/
console.log(which);
}
// All will output: "I am the default"
// This should mean that these are values which are converted as false
myFunction(); //undefined
myFunction(NaN); //Not a number
myFunction(false); //Bool
myFunction(''); //Empty string
myFunction(""); //Empty string
myFunction(null);
myFunction(0);
// Outputs: "Hello World!"
myFunction("Hello World!");
The user interaction part should look like the content as seen below by starting "index.html" in a web browser.
- One of radio
🅱️ uttons "EVEN", "NONE" or "UNEVEN" would have to be selected to set a bet 🅱️ utton "START" should check if the bet was correct- Beneath "START" the text "Result" would be changed after "START" is pressed
- If no bet is set then there should be poping up an error message
To use the project just download the files and execute "index.html". Note that all files(folder "wiki_images" excluded) should be placed in the same folder so that the functionality of the code is guaranteed.
This knowledge was gained:
Effective JavaScript "68 Specific Ways to Harness the Power of JavaScript" by David Herman