-
Notifications
You must be signed in to change notification settings - Fork 288
JavaScript Pretest 2
-
Declare firstName, lastName, age variables and assign your first name, your last name and your age to the variables.
-
Concatenate the firstName , a space and lastName variable and assigned to a fullName variable.
-
Check if your name is long or short. If the length of your first name is greater than 7, you have a long name else you have a short name
-
Declare an array called shoppingBasket and put at least 5 items you commonly put to your shopping basket.
-
Declare a function called sumOfAllNumbers, it takes a positive integer as a parameter and it returns the sum of all the numbers
-
Declare a function called listShoppingItems, it takes your shopping basket array you declared at question 4 as a parameter and it prints out the capitalized shopping items.
const list = [ 'Banana', 'Tomato', 'Milk', 'Egg', ] listShoppingItems(list) BANANA TOMATO MILK EGG
-
Declare a function called getPersonInfo, it takes firstName, lastName, age and country as parameter and it returns information about you. eg.
getPersonInfo('Asabeneh', 'Yetayeh', 200, 'Finland') I am Asabeneh Yetayeh. I am 200 years old. I am from Finland.
-
Declare a function called randomNumbers which can return an array of 7 numbers which range 1-20.
randomNumbers() [9,4, 3, 5, 2, 8, 2]
-
Declare a function called sumOfEven, it takes a positive integer as a parameter and it returns the sum of all numbers
sumOfEven(10)
-
Declare an object called person, it has firstName, lastName, age, country, getPersonInfo keys. The getPersonInfo is a method which return about the person object. eg.
I am Asabeneh Yetayeh. I am 200 years old. I live in from Finland.