Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test is not working, even though requirement is fulfilled #11831

Closed
itsbillyy opened this issue Nov 27, 2016 · 1 comment
Closed

Test is not working, even though requirement is fulfilled #11831

itsbillyy opened this issue Nov 27, 2016 · 1 comment

Comments

@itsbillyy
Copy link

Challenge Find the Longest Word in a String has an issue.
User Agent is: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36.
Please describe how to reproduce this issue, and include links to screenshots if possible.
Test for the third dot point (findLongestWord("May the force be with you") should return 5.) does not tick even though the output satisfies the requirement.

My code:

var array = [];
var z = 0;
function findLongestWord(str) {
  array = str.split(' ');
  var newArray = array.map(function(val){
    return val.length;
  });
  for (i = 0; i <= newArray.length; i++) {
    if (newArray[i] > z) {
      z = newArray[i];
    }
  }
  return z;
}

findLongestWord("May the force be with you");
@erictleung
Copy link
Member

@itsbillyy same issue as #11832. Move your global variables within your function and you should pass the challenge. Happy coding!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants