Please assist with js functions

i keep getting these errors in the bootcamps console.
please help me take assertion and type errors away.

function called getDay which can find out which day of the week a specific date was:

function called yearsAgo that takes in a year and return how many years ago that year is from the current year:

function called sameWeekday that takes in two dates and check if both dates have the same weekday:

this code works in the browsers console but in the bootcamps console. It is giving the desired answers in all 3 images but im still getting errors.

Please do not post screenshots of code. Screenshots are very difficult to work with.

console log your parameters, make sure they are called with the values you expect

all the parameters are in console.log

no, they aren’t
you never have a console.log inside the functions

i tried the console.log inside the function and that gives the same error but without the answer

try to add console.log(arguments) and see if you see what is passed in by the tests

maybe you can also open browser console

the code works in the browser console but not in bootcamps console.

i added console.log(arguments) as well and it gave the full questions.

The code you have above shouldn’t really “work” in the browser console. I don’t think you are using those arguments correctly at all.

Have you looked at the documentation for the Date object?

A JavaScript date is fundamentally specified as the number of milliseconds that have elapsed since midnight on January 1, 1970, UTC

In the first problem, you are using, but weekDays is an array and does not have a date property.

In the second problem, I think you aren’t supposed to have two arguments. You just need the number of years ago the provided date was relative to the current year.

For the same weekday problem, I think you code is actually checking if two dates correspond to the same calendar day, month, and year.

what do you mean that it gave you the full question?

you need to add console.log(arguments) as first line inside the function, and run the code in the environment in which you are tested

if the output is not printed in the console there, it should be printed in the browser console (do not execute it there, see if the log shows up there)

do you have some values printed there?

yes i checked google already. The code wroks fine in the browser console and jsFiddle

it prints the full question and some other data plus the answer and the errors yiu see in the images

I’m pretty sure your getDays just always return undefined, that is not “works well”

that other data should be the arguments that the tests pass in

if you try in getDays with console.log({weekDays, date}) you may see that the values passed in do not correspond to what you expect

1 Like

See my comments above. The code does not match the behavior you describe.

for more help share that “some other data”, and your code, not a screenshot

1 Like