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

added test for object for steamroller bonfire #1573

Merged
merged 1 commit into from
Aug 5, 2015
Merged

added test for object for steamroller bonfire #1573

merged 1 commit into from
Aug 5, 2015

Conversation

Greenheart
Copy link
Member

Now tests if code works with objects.

Incorrect code like the following will not work since it can't handle objects.

function steamroller(arr) {
  arr = arr.toString().split(',');

  for (var i = 0; i < arr.length; i++) {

    test = parseInt(arr[i], 10);

    if ( !isNaN(test) ) {  // if test not is not a num
      arr[i] = test;

    } else if (arr[i] === '') { // Object is '' after .toString(), so remove empty strings

      arr.splice(i, 1);
      i--;
    }
  }

  return arr;
}

@benmcmahon100
Copy link
Member

Has this been tested locally and linted?

@ahstro
Copy link
Member

ahstro commented Aug 5, 2015

I've tested it. I have not linted it, but should not need linting, it's only a single line of JSON.
Which linter is used for JSON, by the way? I've only heard ESLint for the JavaScript.

@benmcmahon100
Copy link
Member

@ahstro i use this http://jsonlint.com/ It requires copy-pasting but it's very good. It most likely doesn't need linting as it's just a one line change but it's a good practice when contributing :p

benmcmahon100 added a commit that referenced this pull request Aug 5, 2015
added test for object for steamroller bonfire
@benmcmahon100 benmcmahon100 merged commit 145cb42 into freeCodeCamp:staging Aug 5, 2015
@Greenheart
Copy link
Member Author

@benmcmahon100 I'll use that one in the future!

@benmcmahon100
Copy link
Member

@Greenheart Thanks for the fix btw! The help is much appreciated!

This was referenced Apr 26, 2021
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

Successfully merging this pull request may close these issues.

None yet

3 participants