question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Caesars Cipher: Correct Values are shown in console.log but still i cannot pass

See original GitHub issue

Challenge Caesars Cipher has an issue. User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36. Please describe how to reproduce this issue, and include links to screenshots if possible.

My code:


function rot13(str) { // LBH QVQ VG!
var res="";	
  for(var i=0;i<=str.length;i++){
  	if((str.charCodeAt(i)==32)||(str.charCodeAt(i)<=64))
  		delta=str.charCodeAt(i);
  	else if((str.charCodeAt(i))>77)
  		delta=str.charCodeAt(i)-13;
  	else 
  		delta=str.charCodeAt(i)+13;
  	res+=String.fromCharCode(delta);
  }
  return res;
}

// Change the inputs below to test
//rot13("SERR");
console.log(rot13("SERR PBQR PNZC"));
console.log(rot13("SERR CVMMN!"));
console.log(rot13("SERR YBIR?"));
console.log(rot13("GUR DHVPX OEBJA QBT WHZCRQ BIRE GUR YNML SBK."));


I made a test in my browser, and it delivers all the correct values, but still i don’t pass.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
rawgnicommented, Nov 15, 2016

for(var i=0;i<=str.length;i++){ should be i < str.length

Your result might look correct, but they actually have a \x0 at the end.

0reactions
Bounceycommented, Nov 15, 2016

What @rawgni said.

@hanhoah please ensure you have asked for help, or that someone could confirm the issue in the Help chatrooms before posting an issue on github. You can access the correct chat room for your challenge by clicking on the Help button in the side panel.

Closing as coding error.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Caesars Cipher / Shift Caesar code is not working
The previous answer is correct (the replace function returns a string, doesn't perform an update on the original input).
Read more >
Discuss Caesar Cipher Helper - Codewars
I solved the Kata and could verify that the output of my function (wrong code) is shown as "expected" and the expected value...
Read more >
freecodecamp: Caesars Cipher - gists · GitHub
Write a function which takes a ROT13 encoded string as input and returns a decoded string. All letters will be uppercase. Do not...
Read more >
Destructuring assignment - The Modern JavaScript Tutorial
Destructuring assignment is a special syntax that allows us to “unpack” arrays or objects into a bunch of variables, as sometimes that's more ......
Read more >
Shift cipher (article) - Khan Academy
The Caesar Cipher is a type of shift cipher. Shift Ciphers work by using the modulo operator to encrypt and decrypt messages. The...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found