Hey guys its been a while in here, and how has coding been?
The code are written with chrome developer tools...
Apparently what I did was I used Math.floor function and Math.random function
Math.random is a function that generates random numbers from 0 to 0.9999999, but can't get to 1
While Math.floor approximates a number to the nearest whole number( it performs this without any regard for the number after the decimal i.e. 4.5 will be approximated to 4 and not 5.
The part where I multiplied by 100 and added +1 is to make sure we have two whole numbers, since we want to approximate the number generated by Math.random we have to multiply by 100, by adding +1 we ensure our answer is never 0.
I also made use of conditional statements ( if, else if, else) to state the conditions at which a boy and a girl can be compatible,
I stated if the number generated is less than 30, they Do not match , else if compatibility test generated is less than 70 but greater than 30, Give it a Trial, else they are a Perfect Match.
I made use of prompt() to display an input to type in the boy and girl's name and alert() to state their compatibility result.
A pop is going to show like this, where you can input your name
An alert will then show like this, stating your compatibility
Thanks for stopping by, ensure to try out this code and input your friends names, Fun! isn't😃
I hope this was helpful...
All images and codes were taken and written by me