Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

JavaScript Pretest 2

Asabeneh edited this pageNov 12, 2019 ·6 revisions
  1. DeclarefirstName,lastName,age variables and assign your first name, your last name and your age to the variables.

  2. Concatenate thefirstName ,a space andlastName variable and assigned to afullName variable.

  3. 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

  4. Declare an array calledshoppingBasket and put at least 5 items you commonly put to your shopping basket.

  5. Declare a function calledsumOfAllNumbers, it takes a positive integer as a parameter and it returns the sum of all the numbers

  6. 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
  7. 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.
  8. Declare a function calledrandomNumbers which can return an array of 7 numbers which range 1-20.

    randomNumbers()[9,4,3,5,2,8,2]
  9. Declare a function calledsumOfEven, it takes a positive integer as a parameter and it returns the sum of all numbers

    sumOfEven(10)
  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.

JavaScript for Everyone

By Asabeneh Shitahun Yetayeh: Instructor and Developer

Clone this wiki locally


[8]ページ先頭

©2009-2025 Movatter.jp