Skip to content

Instantly share code, notes, and snippets.

@ross-u
Last active March 5, 2024 18:59
Show Gist options
  • Save ross-u/02d748b20fbd138b9919b71ec1f373ca to your computer and use it in GitHub Desktop.
Save ross-u/02d748b20fbd138b9919b71ec1f373ca to your computer and use it in GitHub Desktop.
JS | Functions - Syntax Exercise

JS | Functions


Syntax - Exercise

Let's practice the function syntax:


Task 1

Create function called getFullName using function declaration syntax.

The function should take 2 arguments, firstName and lastName and return a new string representing the full name.

// Your code here

console.log( getFullName('Bob', 'Smith') ); //  expected: Bob Smith

Task 2

Create the same function as a function expression, but this time name it getFullNameExpr.

// Your code here

console.log( getFullNameExpr('Sarah', 'O\'Connor') ); //  expected: Sarah O'Connor

Task 3

Create the same as arrow function, but this time name it getFullNameArrow.

// Your code here

console.log( getFullNameArrow('Axel', 'Garcia') ); //  expected: Axel Garcia

Bonus -

Update the function getFullNameArrow to use the concise arrow function syntax.

// Your code here

console.log( fullNameArrow('Esther', 'Bernal') ); //  expected: Esther Bernal
// TASK 1
// Your code here
console.log( getFullName('Bob', 'Smith') ); // expected: Bob Smith
// TASK 2
// Your code here
console.log( getFullNameExpr('Sarah', 'O\'Connor') ); // expected: Sarah O'Connor
// TASK 3
// Your code here
console.log( getFullNameArrow('Axel', 'Garcia') ); // expected: Axel Garcia
// BONUS TASK
// Your code here
console.log( getFullNameArrow('Esther', 'Bernal') ); // expected: Esther Bernal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment