vendredi 22 février 2019

How to increment a value of y based on x in javascript

I know this is a simple question but I am quite new to coding. I want an if function that determines Y from the value of X like so:

if the value of x is 1.5, then y is 20. For every 0.1 deviation in x, lower the value of y by 0.3

So if x is 1.5, y will be 20. If x is 1.6, y will be 19.7. If x is 1.3, y will be 19.4, and so on.

I have started this

if (x = 1.5){
    y = 20;
}  else {

    }

How should I complete this function ?

Aucun commentaire:

Enregistrer un commentaire