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 trialmoshe levi
2,953 Pointsconfusion
does anyone could explain me what is this
function compare(a, b) {
console.log(a + "<" +b, a < b);
}
1 Answer
Jacob Miller
12,466 PointsIt's a function that takes two arguments, the first represented by a
, and the second by b
. It then logs to the console a message that says a < b
, followed by the result of mathematically comparing the two, which will either be true
or false
So in the case of:
function compare(2, 10) {
console.log(a + "<" b, a < b);
}
The number 2 is substituted for a
, and the number 10 is substituted for b
. The result of running the function would be this message logged to the console: 2 < 10, true