# Problem with .fromCharCode() in Cipher

Problem with .fromCharCode() in Cipher
0

#1

I’ve got an array of numbers that represent a word plus 13. But when I try to convert it back to numbers it does not work. I might be using it wrong but it’s what I saw in the MDN docs. Particularly starting with `String.`

Word to unicode plus 13
the word TEST => `[ 97, 82, 96, 97 ]`

So
`var arr = [ 97, 82, 96, 97 ]`

``````for (var i = 0; i < arr.length; i++) {
console.log(String.fromCharCode(arr[i]))
}
``````

`returns => a R ' a`

But why?

#2

The reason your code above prints a R ’ a is because those are the ascii codes for those characters and your are looping through and converting them to those codes.

Remember that ascii codes 65-90 represent the upper case letters A-Z. Ascii code numbers before and after the 65-90 range are going to be different. You need to think about how you will adjust your plus 13 codes back into the 65-90 range so those numbers will convert to letters ranging from A-Z.

#3

So say if it needed to be raised by 13, and the starting point was 85, it would not be 98? Would it revert to the start again?

85 + 13, would be 68? This is just the solution that comes to mind based on what U said.

I didn’t get any of this from the information out of the original problem. I guess it makes sense (if I am interpreting correctly)

#4

Adding 13 to 85 would be 98 but that really means 8 past 90, so you would need need to think of 90 as one below 65 (or 64) and then add 8 to it to arrive at 72.

#5

Oh, I thought it was between 60-90. So that was what I meant but 68.

I still don’t know how we even would have know this though.

I only learned about this being between the range 60-90 (incorrectly), and now 65-90, from reading the forum questions and from asking. It’s not something I ran into and I did read the docs.

Anyway, thanks!

#6

I remember thinking the same thing on other challenges. Most of the time, the hints will have links to more reading material. If you click on the link for charCodeAt in the hint section, you would see the reference to a few of the codes (i.e. 65 => “A” and the term ascii codes in general. The point of this challenge was to get you to research on your own to figure out what you needed to learn to solve the problem. For the intermediate and advanced algorithm challenges, you will definitely be doing research.

Sometimes when researching for a particular challenge, you may discover other ways of coding solutions you have already solved.