Tell us what’s happening:
I am getting “message: getDataFormats() should return [“2019-1-15”, “Tuesday, January 15, 2019”].” when I run the tests against the Rosetta Code: Date format challenge, yet when using console.log(), the array looks correct.
Your code so far
function getDateFormats () {
// Good luck!
let dateTime = new Date;
let newArray = [];
const monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
const dayNames = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"];
let firstSpot = dateTime.getFullYear() + '-' + (1 + dateTime.getMonth()) + '-' + dateTime.getDate();
// Push to array
newArray.push(firstSpot);
let secondSpot = dayNames[dateTime.getDay()] + ', ' + monthNames[dateTime.getMonth()] + ' ' + dateTime.getDate() + ', ' + dateTime.getFullYear();
// Push to array
newArray.push(secondSpot);
console.log("Array: " + newArray);
return newArray;
}
getDateFormats();
// Error when running test
//message: getDataFormats() should return ["2019-1-15", "Tuesday, January 15, 2019"].
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/coding-interview-prep/rosetta-code/date-format