Thursday, April 29, 2021

Javascript Practice 06: JS Hero - Functions

Question: 

Define a function hello that returns 'Hello world!'.





Answer: 

function hello () {

return 'Hello World!"; 

}; 


JS Function Syntax: 

Keyword: function

Name of the function: hello

Parameters within Parentheses: ()

Body within Curly Brackets: { return 'Hello World!'; };

Note: 

return statement determines the value the function returns

Always use semi-colons in your code to avoid errors






 

No comments:

Post a Comment