create account

BUILDING A LOVE CALCULATOR WITH JAVASCRIPT by joebolite97

View this thread on: hive.blogpeakd.comecency.com
· @joebolite97 · (edited)
$20.61
BUILDING A LOVE CALCULATOR WITH JAVASCRIPT
###### Hey guys its been a while in here, and how has coding been? 
###### I would like to share with you guys what I learnt today. I picked up JavaScript for beginners after I wrote a post on [JavaScript Frameworks](https://peakd.com/hive-169321/@joebolite97/javascript-frameworks-and-types), and I must admit it hasn't been an easy ride.

In this post I will be showing you the logic I  used to make a simple love calculator using JavaScript.
The code are written with chrome developer tools...


![Screenshot 2022-08-04 114218.png](https://files.peakd.com/file/peakd-hive/joebolite97/23vsqueDg7AhEybiNeXpx7pYVZkULowcrk7j723QPsutCJT7hUNTtip5fTjJ4zLJ856jJ.png)

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.

![Screenshot 2022-08-04 114234.png](https://files.peakd.com/file/peakd-hive/joebolite97/Eo8ZaTRLqqQjgvoTYomPUQUgP5RLefqhjryHtyu18Aw3LcQ4KaHAjpxNqdYW4yVRHKY.png)

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. 

![Screenshot 2022-08-04 123308.png](https://files.peakd.com/file/peakd-hive/joebolite97/23tcNhoPzQdR8LvDUktyUqA35gUd7aMLbYr8Ux674SsbLWPqq2GN9eJGRgRhsiVmr9KZU.png)

A pop is going to show like  this, where you can input your name


![Screenshot 2022-08-04 125649.png](https://files.peakd.com/file/peakd-hive/joebolite97/23u6YrC5UKS1Tn85Pfvt6zxT9j67oNTB9X7PuHCqTsLeUmYQpCRsmeYjtvMp1k4avA8WF.png)


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😃
![text16.png](https://files.peakd.com/file/peakd-hive/joebolite97/246FZMwteQQMEgT4iDyeTv2vw9QqRZ9UhFG7im6TzvjxJG9Je1D8LFuYrZk8PwdbbPNBm.png)

I hope this was helpful...
Until time, 
Stay woke✌️
*All images and codes were taken and written by me*
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 225 others
👎  
properties (23)
authorjoebolite97
permlinkbuilding-a-love-calculator-with-javascript
categoryhive-169321
json_metadata{"app":"peakd/2022.07.1","format":"markdown","tags":["programming","development","neoxian","palnet","code","ocd","archon","hive","steem","javascript"],"users":["joebolite97"],"image":["https://files.peakd.com/file/peakd-hive/joebolite97/Eo8ZaTRLqqQjgvoTYomPUQUgP5RLefqhjryHtyu18Aw3LcQ4KaHAjpxNqdYW4yVRHKY.png","https://files.peakd.com/file/peakd-hive/joebolite97/23vsqueDg7AhEybiNeXpx7pYVZkULowcrk7j723QPsutCJT7hUNTtip5fTjJ4zLJ856jJ.png","https://files.peakd.com/file/peakd-hive/joebolite97/23tcNhoPzQdR8LvDUktyUqA35gUd7aMLbYr8Ux674SsbLWPqq2GN9eJGRgRhsiVmr9KZU.png","https://files.peakd.com/file/peakd-hive/joebolite97/23u6YrC5UKS1Tn85Pfvt6zxT9j67oNTB9X7PuHCqTsLeUmYQpCRsmeYjtvMp1k4avA8WF.png","https://files.peakd.com/file/peakd-hive/joebolite97/246FZMwteQQMEgT4iDyeTv2vw9QqRZ9UhFG7im6TzvjxJG9Je1D8LFuYrZk8PwdbbPNBm.png"]}
created2022-08-04 12:02:33
last_update2022-08-04 12:26:21
depth0
children5
last_payout2022-08-11 12:02:33
cashout_time1969-12-31 23:59:59
total_payout_value10.138 HBD
curator_payout_value10.473 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length2,699
author_reputation13,174,697,412,119
root_title"BUILDING A LOVE CALCULATOR WITH JAVASCRIPT"
beneficiaries
0.
accounthive-169321
weight200
1.
accounthiveonboard
weight100
2.
accountocd
weight100
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id115,424,197
net_rshares27,465,387,995,299
author_curate_reward""
vote details (290)
@macchiata ·
This is a fun project and exercise! 
properties (22)
authormacchiata
permlinkre-joebolite97-rg45sl
categoryhive-169321
json_metadata{"tags":["hive-169321"],"app":"peakd/2022.07.1"}
created2022-08-04 23:12:21
last_update2022-08-04 23:12:21
depth1
children3
last_payout2022-08-11 23:12:21
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length36
author_reputation1,415,812,865,903,314
root_title"BUILDING A LOVE CALCULATOR WITH JAVASCRIPT"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id115,442,372
net_rshares0
@joebolite97 ·
Yeah it's really fun...
Especially when you start inputting your friends names a seeing funny results

Thanks for stopping by really appreciate 
properties (22)
authorjoebolite97
permlinkre-macchiata-rg4jge
categoryhive-169321
json_metadata{"tags":["hive-169321"],"app":"peakd/2022.07.1"}
created2022-08-05 04:07:30
last_update2022-08-05 04:07:30
depth2
children2
last_payout2022-08-12 04:07:30
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length144
author_reputation13,174,697,412,119
root_title"BUILDING A LOVE CALCULATOR WITH JAVASCRIPT"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id115,448,216
net_rshares0
@macchiata ·
Right?! I am going to try this out when I have free time. 
properties (22)
authormacchiata
permlinkre-joebolite97-rg4s36
categoryhive-169321
json_metadata{"tags":["hive-169321"],"app":"peakd/2022.07.1"}
created2022-08-05 07:13:54
last_update2022-08-05 07:13:54
depth3
children1
last_payout2022-08-12 07:13:54
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length58
author_reputation1,415,812,865,903,314
root_title"BUILDING A LOVE CALCULATOR WITH JAVASCRIPT"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id115,451,340
net_rshares0
@stemsocial ·
re-joebolite97-building-a-love-calculator-with-javascript-20220804t181538800z
<div class='text-justify'> <div class='pull-left'>
 <img src='https://stem.openhive.network/images/stemsocialsupport7.png'> </div>

Thanks for your contribution to the <a href='/trending/hive-196387'>STEMsocial community</a>. Feel free to join us on <a href='https://discord.gg/9c7pKVD'>discord</a> to get to know the rest of us!

Please consider delegating to the @stemsocial account (85% of the curation rewards are returned).

You may also include @stemsocial as a beneficiary of the rewards of this post to get a stronger support.&nbsp;<br />&nbsp;<br />
</div>
properties (22)
authorstemsocial
permlinkre-joebolite97-building-a-love-calculator-with-javascript-20220804t181538800z
categoryhive-169321
json_metadata{"app":"STEMsocial"}
created2022-08-04 18:15:39
last_update2022-08-04 18:15:39
depth1
children0
last_payout2022-08-11 18:15:39
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length565
author_reputation22,941,669,144,741
root_title"BUILDING A LOVE CALCULATOR WITH JAVASCRIPT"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id115,434,098
net_rshares0