Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

could someone check my code in JavaScript please.

https://w.trhou.se/b2354pv9jn

just checking if my function and if statements are good. (I'm practising).

plus also at line 22 that changing the condition of the code is ok.

thanks for your time.

5 Answers

No worries, glad you got there.

Well, everything looks good to me; it works as intended! You could, of course, also extend your experiment by assigning the message variable to an HTML element for display? Well done anyway. You clearly get it! Passing arguments to a function is not trivial. Best Robin

I think I know clearly what a parameter is:- like a variable that holds a value passed to the function. But an argument still even though I've seen them many times i cant get my head around them. ( Just my mind wont accept them :-) )

Your previous comment would it be like this:- document.querySelector("main").innerHTML = (<p>message</p>);

I'm so not used to that at all, probably wrong..

That helps thank you so much, I think I shy away from getting to grips with arguments and it shows, so I will try harder there, your analogy is a good example of how to think about comparing the two. :-)

clock is the parameter, and the number you apply to it (e.g. 10) is the argument. - I have wrote that into my code comments.

I've noticed that as long as each day I try to read something and program a little I will get better and better at this type of thing.

Thanks for all your time. Merry Christmas :-)

You're welcome. Merry Christmas to you too, and I wish you a better New Year.

Hi Jason

Happy to have a look.... but could you paste the code? ...can't access your workspace.

Cheers Robin

I've updated the file path.

Still not. Might be me ;) But if you go to your workspace there is a camera icon top right (first of 3 icons), then share that?

Maybe that works. Best Robin

haha updated again! sorry Robin its me I was consistently pasting the wrong link, apologises. Thanks for your patience!

Hi

First of all, parameters v arguments. They way I understand it is something like the following rather stretched analogy....;) When you go to the supermarket you take a basket/trolley, right? This is the basket that represents the function () (even looks a little like a basket). And the job of that basket is to hold things that you choose. We could call the things that you choose, 'parameters'. Not yet specific, but you know what sort of things you're going to buy! The argument(s) are the actual things that you choose to put in the basket and buy. The actual things that go through the till, get put in your bags, etc. i.e. they are processed by the function(s), and subsequently return a value of some kind.

So - parameters are placeholders, whereas arguments are the actual values applied. In your example, clock is the parameter, and the number you apply to it (e.g. 10) is the argument.

As for creating something from your javascript in HTML (via the DOM!), you might want to look up innerHTML and textContent. MDN (Mozilla) is the best place to search, and W3Schools will have some straightforward examples.

Good luck going forward with the course,

Robin