Skip to content

Instantly share code, notes, and snippets.

@appoll
Created May 31, 2021 17:29
Show Gist options
  • Save appoll/6f3c4c163442bf7b71bac6ec5b50bd60 to your computer and use it in GitHub Desktop.
Save appoll/6f3c4c163442bf7b71bac6ec5b50bd60 to your computer and use it in GitHub Desktop.
// Before you write your own function, answer 2 questions:
// 1. What should the function do? (the action)
// 2. What does it need? (the parameters)
function helloUser(userName, userAge){
console.log("Hello, " + userName);
console.log("You are " +userAge+ " years old");
}
helloUser("Flavia", 23);
helloUser("Jannek", 24);
// E0.
// Write a function that builds a string which contains the same word more times.
// The word and the number of times should be passed in as parameters.
// printWordManyTimes("hello", 5);
// hellohellohellohellohello
function singSong(word, count){
}
// E1.
// Write a function that prints the sum of two numbers.
// The 2 numbers should be passed in as parameters
// e.g. add(3,5)
// E2.
// A function that takes an array as a parameter
// The function should print every element in the array
// e.g. printArrayElements([3,5,7])
// Bonus:
// Write a function that takes an array as a parameter and
// prints only the unique elements of the array.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment