citronic
citronic

Reputation: 10168

how do i get the numeric representation of a character in javascript?

I'd like to get a javascript numeric representation for a letter to do some relative manipulation i.e. in pseudocode to conduct an operation like 'a'.getNumberRep - 'b'.getNumberRep.

Best way to do this in js?

Upvotes: 0

Views: 1393

Answers (1)

moonshadow
moonshadow

Reputation: 89065

'a'.charCodeAt(0) - 'b'.charCodeAt(0)

Upvotes: 5

Related Questions