How can I convert this PHP code to JavaScript?
$string = "string How Long is a Piece of String?";
if (strlen($string) < 5)
{
echo "string is less than 5";
}
else
{
echo "string is more than 5";
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I assume this is just a really convoluted, badly explained, typo-ridden way of asking how to get the length of a string in JavaScript. If that’s the case, just check the length property of the string, like this:
If this is not what you’re asking, you really need to clarify the question.