Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # JS | Functions
- <br>
- ## Syntax - Exercise
- Let's practice the function syntax:
- <br>
- **Task 1**
- Create function called `fullName` using *function declaration* syntax.
- The function should take 2 arguments, `firstName` and `lastName` and `return` a new string representing the full name.
- ```js
- // Your code here
- console.log( fullName('Bob', 'Smith') ); // expected: Bob Smith
- ```
- <br>
- **Task 2**
- Create the same function as a function expression, but this time name it `fullNameExpr`.
- ```js
- // Your code here
- console.log( fullNameExpr('Sarah', 'O\'Connor') ); // expected: Sarah O'Connor
- ```
- <br>
- **Task 3**
- Create the same as arrow function, but this time name it `fullNameArrow`.
- ```js
- // Your code here
- console.log( fullNameArrow('Axel', 'Garcia') ); // expected: Axel Garcia
- ```
- <br>
- **Bonus** -
- Create the same function as concise arrow function.
- ```js
- // Your code here
- console.log( fullNameArrow('Esther', 'Bernal') ); // expected: Esther bernal
- ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement