samedi 12 août 2023

Math.random() works on localhost, but always returns 0 on Hostinger

The purpose of this code is to change my coordinates slightly before posting them, for purposes of security. When I test the code on my WAMP localhost, I find it works as I intended. When testing on a live website, it behaves as if Math.random() is always returning 0.

var latitude =  randomize($(this).attr('Tlatitude'));  //get string from mysql and randomize

function randomize(angle){
    return `${(parseFloat(angle) + ((Math.random() -0.5 )* 0.006))}`;   //change it no more than 0.2 nm.
}

Any ideas? My live website troubleshooting skills are not highly developed.

Doug




Aucun commentaire:

Enregistrer un commentaire