Challenge 9 Megathread

Welcome to challenge 9! Use this thread for any and all questions relating to challenge 9.

1 Like

This is strange. Test code says I pass all the tests, but Submit says no.

Here is my code:

3 Likes

I’m getting the same error even though all test pass as well.

3 Likes

Me too. How do we alert the organisers when things are playing up?

1 Like

I think they’ll fix it. There was a similar problem about 3 days ago.

1 Like

Same issue here. @Tim-Lighthouse-Labs there’s something wrong with the submitter, please fix!

I think I’ve found a 2nd glitch possibly (or I’m still too new)? My code is the same 1 or 2 line solution as everyone else and it passes the test… but I added some console.logs to see what’s going on in the print log:

-If you add a console.log(cars) statement before and after your code, they output the same thing? Shouldn’t they be different?
-The screenshot of my logs below might make it more clear.

const carPassing = (cars, speed) =>{

console.log(‘The last element in INITIAL cars array is:’);
console.log(cars[(cars.length-1)]);
console.log(“INITIAL cars array:”);
console.log(cars);

cars.push({“time”: Date.now(), “speed”:speed});

console.log(‘The last element in UPDATED cars array should be:’);
console.log(cars[(cars.length-1)]);
console.log(“UPDATED cars array:”);
console.log(cars);
console.log("------------------------------");

return(cars);
};

Same problem with testing (passes) and submitting (fails) my code.

Yeah, same here. While the console output matches the expected result (having the latest object being the newest). I even added a sorter function, but did not pass either:

const carPassing = (cars = [], speed = 0) => {
return […cars, {time: Date.now(), speed}]
}

I am facing the same issue…

const carPassing = (cars, speed) => {
  return [...cars, { time: Date.now(), speed}]
}

I’m also getting the same problem where it is passing all the test cases and then state I have a failing test case when submitting.

same error when submitting as well

Apologies everyone. Small error in the private tests has been updated and fixed. Try again now :slight_smile:

1 Like

I don’t know about the whole issue, but you are specifying the last item in your array because arrays initialize at 0, not 1. So an array with length 3 [‘a’,‘b’,‘c’] has a ‘c’ at position 2 which you would get with array[array.length-1].
Hope that helps and makes sense!

My solution:

21%20AM

I had errors with some basic submissions this morning also. Made me a little angry in the moment.

When I submitted with the Date.now() wrapped in parseInt() or Number() converting the type of the date to a number, it worked. A sometimes useful trick or requirement if coding in typescript.

I don’t get it that what I missed:
image

const carPassing = (cars, speed) => {
  var val = new Object{};
  val.time=Date.now();
  val.speed=speed;
cars.push(val);
console.log(cars);
}

I also tried this :

var val = new Object();

It still not work out~
Who can help me to understand what’s really going on?
Thanks~

@BettyH To use the new object function you will need to define the “format” of the object with a constructor. Check out the section on classes within the link provided in today’s hint: