mercredi 23 janvier 2019

Problems with if statements

I have a simple javascript that will check if a variable is empty and if it is empty assign a random string to the variable

I have some code but it just keeps showing as null when the variable is empty instead of the random script

 `enter code here`var myId = getParameterByName('check');

enter code here// The functions

enter code hereif (myId) enter code here{ enter code here var myId = function () enter code here { enter code here return Math.random().toString(36).substr(2); enter code here }

enter code here}

The expected result is if check is =5 then the variable myId should equal 5, if check equals null or empty then the myId variable should be a random string

Aucun commentaire:

Enregistrer un commentaire