Printing variables to console


#1

I am doing a project in the JavaScript lessons. I am at the very beginning of the lessons. I am trying to finish the Dog Years project and it wants me to print two variables to the console. They also want me to do this using console.log(). I am totally stuck.


#2

And why is this a problem? console.log() shouldn’t be something new, right?


#3

Right it’s not new but I’m not sure how to insert two variables into it. Everything I try comes back with an error.


#4

you could check documentation:

https://developer.mozilla.org/en-US/docs/Web/API/Console/log

if you get an error, i can only help you if i get the code so i can reproduce the problem


#5
const myAge = 2;
let earlyYears = 2;
earlyYears *=10.5;
let laterYears = myAge - 2;
laterYears *=4;
//Multiply laterYears
console.log();

If you’d like to check your work at this point, print earlyYears and laterYears to the console. Are the values what you expected?
Check off this task when you’re ready to move on.
Hint

Use console.log() to print to the console.

This is what I am trying to do right now. The top is what I have as of now. The bottom is the step of the project that I am stuck on. I am not sure what have I done wrong or what it is that I am not seeing or doing.


#6

here:

console.log();

you pass no arguments to console.log(), why?


#7

I haven’t saved any of it cause it puts out errors when I run it


#8

what have you attempted to produced errors?

https://www.codecademy.com/courses/learn-javascript-introduction/projects/dog-years?course_redirect=introduction-to-javascript

url for quick exercise access for me.

you can simply pass multiple arguments to a method by separating them by a comma (it was in the documentation i linked to)


#9

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.