Reputation: 9
I have scoured the web for an hour-and-a-half looking for a working, simple string-to-decimal function, and have been depressingly failed. The mentioned string is comprised of letters and numbers. This is meant for a cipher. I would like something like this...
function ConvertDec(str){
//do conversion
return decVal;
}
Were it would be used as such...
decSeed = ConvertDec(seed);
decUserString = ConvertDec(strVal);
These values would then be multiplied to get a full value, which would later be decrypted.
Upvotes: 0
Views: 49
Reputation: 77816
Here's the basics
var str = "123.45";
var dec = parseFloat(str);
console.log(dec); // 123.45
Read more about parseFloat
here
Upvotes: 2