Print all even numbers from array?

I thought you typically wrote your code for these challenge in the bootcamp’s editor and ran the tests. It appears you are writing your code in the browsers console?

Anyway, it appears there are two tests. The first test uses [5, 20, 11, 42, 2, 19] as the input. Using this input, your function should return [20, 42, 2]. Since I can not see the test script they are using, I am not sure why you are getting the following message:

AssertionError: expected 0 to equal 3
at (test/main.js:18:12)

What I can tell you, is your function does return an array of only even numbers for any given array of numbers passed in to it.

Usually I am, but this portion is involving Git and checking the code in the Terminal. The section involves 3 problems (question0, question1, question2) and it seems like I passed the other two, but the first one (this thread) doesn’t seem to pass:

Sorry, I am out of ideas at this point. You would need to contact the creator of the tests or look through the text/main.js code and see what it shows for line 18.

It’s funny, 'cause on line 18, it’s only the directions for the next problem. (They require you to write in Atom, usually I like VS Code.)

So you are writing all the code in the file located at test/main.js?

If I’m not mistaken, I believe so. I have waited too long to learn Git and now it has become a regret of mine.

How can you not know what the file name is you are entering code into? When using your Atom editor or VS Code editor, it should show you the file name and path to the file (at least in Atom).

Yes, it is. Typical fork and clone repository, solve functions, test in terminal, then commit back.

What exactly do you manually have to type in the terminal screen to test your code?

“npm test”

This is of course after I “cd” into the directories and get to the file.

If I could look at the package.json file, it would be helpful. Do you see that file in the repository?

I don’t see how this is anything to do with git. The test isn’t passing, so you need to see why that is the case, git has nothing to do with it. The tests are definitely there and the tests are running, but you need to find out what the test is actually testing for.

  "name": "js-loops-and-conditionals-assessment",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "./node_modules/.bin/mocha"
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "chai": "^3.5.0",
    "mocha": "^3.2.0",
    "mocha-sinon": "^1.1.6",
    "sinon": "^1.17.7"

Yes, I understand thanks. Just learning Git now, so I’m still a noobie. Always gonna be.

It’s nothing to do with git, you need the file where the test for that function is defined

I know it has nothing to do with Git lol. I’m telling you with conjunction of this problem and the fact that it requires me to use Git (which I am just learning now), it complicated it a bit for me.

What I’m getting at is: what is the test for that function? I can see everything is running fine, but the test expects some return value to match 3 for that function, which does not seem to match the instructions. The test file has to be in a folder right next to the file you’re working on

Maybe this is it?

const chai = require('chai')
const assert = chai.assert
const main = require('../src/main')

// Listen for console.log statements
function stubFn () { this.sinon.stub(console, 'log') }

describe('main', () => {


  it('question0', () => {
    var input = [ 5, 20, 11, 42, 2, 19 ]
    var expected = [ 20, 42, 2 ]

    assert.equal(console.log.callCount, expected.length)
    expected.forEach(num => assert.isTrue(console.log.calledWith(num)))

Jesus Christ that’s a horrible test

LOL why is that? Hahahahahaha