Caesars Cipher null output

Caesars Cipher null output
0

#1

**Tell us what’s happening:**I’m getting the correct number of output characters in the last array, but each character is showing as null. Why is this happening?

Your code so far

function rot13(str) { // LBH QVQ VG!
  str = str.toUpperCase();
  var cipherText = [];
  for (var i = 0; i < str.length; i++){
    cipherText[i] = str.charCodeAt(i);
   
  }
  //return cipherText;
  var cipher = cipherText.map(function(num) {
  if (num < 65 || num > 90){
	  return num;
  }
  else if (num < 78){
    return num + 13;
  }
  else {
    return num - 13;
  }
});
  var clearText = cipher.map(function(num){
    
    String.fromCharCode(num);
  });
  return clearText;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.75 Safari/537.36.

Link to the challenge:


#2

Your cipher.map's function is not returning anything.


#3

The last return statement is returning cleartext. I get the following in the console: [null, null, null, null, null, null, null, null, null, null, null, null, null, null]. There are 14 entries just as there are 14 characters in the test phrase.


#4

Like @kevcomedia said already, your map function is not returning a value. All your map function does is

String.fromCharCode(num);

but this evaluation above does not get returned and it should. Also, the map function (once you fixed the return issue) creates a new array, so in your final function return you need to convert that array back to a string to solve the challenge.