Home Need to convert var (a word or sentence) into integer dependent on string length
Reply: 2

Need to convert var (a word or sentence) into integer dependent on string length

Johnny Mayer
1#
Johnny Mayer Published in 2018-01-12 18:52:21Z

As the title says, I need to convert a variable myVariable (in my case, a sentence, phrase, or single word) into an integer determined by the length of the myVariable.

So far I've tried:

var userName = $("#userName").val(userName.length);
var userName = $("#userName").val(length.userName);
var userName = $("#userName").val(parseInt.userName());

I've been at this a while now and am getting nowhere.

Twisty
2#
Twisty Reply to 2018-01-12 18:56:16Z

To start, collect the current value:

var userName = $("#userName").val();

Not you can get the length:

var userNameLength = userName.length;

Hope that helps.

Mark Schultheiss
3#
Mark Schultheiss Reply to 2018-01-12 18:57:17Z
var myVariable= "fred flew the bird";
var userName = $("#userName").val(myVariable.length);
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.301805 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO