javascript - Multiplying a letter by a number -


trying around javascript code looking at. seeing things this:

var myvariable = "x"; var result = myvariable * 6; 

coming c# background, new me. give me quick primer on going on here? guessing result equal letters position in alphabet multiplied 6, correct?

i guessing result equal letters position in alphabet multiplied 6, correct?

no. js weakly typed, , values implicitly typecasted match operator (a multiplicative one here). in case, string "x" converted number - leading nan it's no valid numberic literal. result nan well.

to position in alphabet, you'd use parseint function non-decimal base (parseint("x", 36)-10) or charcodeat string method ("x".charcodeat(0)-65).


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -