Skip to content

Instantly share code, notes, and snippets.

@McLarenCollege
Last active October 27, 2021 11:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save McLarenCollege/9a5af947f50935577e265897132be9f4 to your computer and use it in GitHub Desktop.
Save McLarenCollege/9a5af947f50935577e265897132be9f4 to your computer and use it in GitHub Desktop.
Exercise : Full Name

Task 1

Given three variables firstName, middleName, lastName, write the code to put all the three variables in an array and return the array

let firstName = "John";
let middleName = "P";
let lastName = "Smith";
function getFullName(firstName, middleName, lastName){

// write code here

}
getFullName(firstName,middleName,lastName);// should return ["John","P","Smith"]

Task2

Given an array containing the firstName, middleName and lastName , write a function that returns a string with the three names separated by '-'

let nameArray=["John","P","Smith"];
function printFullName(nameArray){
// write your code here
}
printFullName(nameArray);// should return "Jon-P-Smith"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment