educative.io

Educative

Console.log & return

What is the different between console.log and return


Type your question above this line.

Course: https://www.educative.io/collection/10370001/5686791109607424
Lesson: https://www.educative.io/collection/page/10370001/5686791109607424/5735735550279680

Hey!

So console.log allows a developer to print messages in the console of the browser. Like the error shown below.

Now whenever the author is talking about return you can safely assume they are talking about the return syntax from JavaScript. A function can return any data type.

So for example in

var paragraphs = document.getElementsByTagName('p')

the document.getElementsByTagName('p') statement would return all the elements by the tag name p and would store it in the paragraphs variable.