Question:
Write a function log that logs 'Hello Console!'. If you are working with a desktop browser, open the developer tools to see the output there as well.
Answer:
function log() {
return 'Hello Console!';
};
console.log(log());
> This is a function declaration & not a function expression
> name of the function: log
> parameter: () no parameter
> statement: return 'Hello Console!'; enclosed in curly brackets
> the function must have a return statement that specifies the value to return
> used the console.log method to display Javascript values in the browser
> console.log is a function in Javascript
> usually console.log is used for debugging purposes
> if a function is passed to console.log(log()), then the function console.log() will display the value of the passed function() in the console - Hello Console!
No comments:
Post a Comment