- Notifications
You must be signed in to change notification settings - Fork307
JavaScript Pretest 2
DeclarefirstName,lastName,age variables and assign your first name, your last name and your age to the variables.
Concatenate thefirstName ,a space andlastName variable and assigned to afullName 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 calledshoppingBasket and put at least 5 items you commonly put to your shopping basket.
Declare a function calledsumOfAllNumbers, it takes a positive integer as a parameter and it returns the sum of all the numbers
Declare a function calledlistShoppingItems, it takes your shopping basket array you declared at question 4 as a parameter and it prints out the capitalized shopping items.
constlist=['Banana','Tomato','Milk','Egg',]listShoppingItems(list)BANANATOMATOMILKEGG
Declare a function calledgetPersonInfo, it takesfirstName,lastName, age andcountry as parameter and it returns information about you. eg.
getPersonInfo('Asabeneh','Yetayeh',200,'Finland')IamAsabenehYetayeh.Iam200yearsold.IamfromFinland.
Declare a function calledrandomNumbers which can return an array of 7 numbers which range 1-20.
randomNumbers()[9,4,3,5,2,8,2]
Declare a function calledsumOfEven, it takes a positive integer as a parameter and it returns the sum of all numbers
sumOfEven(10)
Declare an object calledperson, it hasfirstName,lastName,age,country,getPersonInfo keys. The getPersonInfo is a method which return about the person object. eg.
IamAsabenehYetayeh.Iam200yearsold.IliveinfromFinland.