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.

Reverse a string - not accepting correct solution

See original GitHub issue

Challenge Reverse a String has an issue. User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.81 Safari/537.36. Please describe how to reproduce this issue, and include links to screenshots if possible. I can complete the assignment with unshift but wanted to create this function to reuse in the other algorithm challenges. My output seems correct but is not registering as being correct.

My code:


function reverseString(str) {
  var retstr="";
  var l=str.length;
  for (var i=0; i<str.length; i++){
    retstr+=(str[l-i-1]);
  }
 
  retstr="\""+retstr+"\"";
  
  
  
  return retstr;
}

reverseString("Howdy");

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
tpoikelacommented, May 4, 2017

I think your line retstr="\""+retstr+"\""; is the problem. There is no need to add the double quotes around the reversed string.

1reaction
Margaret2commented, May 6, 2017

Yeah, that is not the correct solution @tgardiner88 For reverseString("Howdy");, your function returns ""ydwoH"", when it should return "ydwoH"

Read more comments on GitHub >

github_iconTop Results From Across the Web

Reverse a string without affecting special characters
Given a string, that contains a special character together with alphabets ('a' to 'z' and 'A' to 'Z'), reverse the string in a...
Read more >
Leetcode Reverse String problem not accepting in-place ...
As I understand, both solutions are in-place. However, solution 1 is not accepted and prompts as wrong answer. Solution 2 is accepted. Could ......
Read more >
Reverse String - LeetCode
Write a function that reverses a string. The input string is given as an array of characters s . You must do this...
Read more >
Reverse a String - Four JavaScript Solutions
The reverse a string problem is a common algorithm problem. In this article, we will consider four JavaScript solutions to it.
Read more >
Reverse String | LeetCode 344 | C++, Java, Python - YouTube
LeetCode Solutions : https://www.youtube.com/playlist?list=PL1w8k37X_6L86f3PUUVFoGYXvZiZHde1SJune LeetCoding Challenge: ...
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