일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
- 헤어브러쉬추천
- 코딩 공부
- props
- 생활코딩
- 데이터베이스
- 테드대본
- 머리빗추천
- window
- relationship
- 탱글티저웻디탱글러
- GIT
- 함수표현식
- 깃 설치
- 자바스크립트
- javascript
- ERD
- Code school
- 리액트
- 함수선언문
- function declaration
- 윈도우
- function expression
- 자바스크립트 함수
- install
- 코드스쿨
- 인프런
- react js
- exerd
- 송도버스시간표
- 직장인마우스
- Today
- Total
J's Rhapsody
[Javascript]문제 1.5: Functions as Parameters, Arguments and Return Values 본문
[Javascript]문제 1.5: Functions as Parameters, Arguments and Return Values
J's Rhapsody 2018. 1. 11. 13:14Functions as Parameters, Arguments and Return Values
Well, it stands to reason that some people might not want to experience the Haunted Hickory House if the fear is significantly elevated on that day.
Inside the
fearMessage
function expression, use conditional statements (e.g.,if
,else if
) to check the integer value of thefear
variable, assigned on line 1, and decide whether its value is LOW or MEDIUM.For each
fear
range below we want to display a confirmation message with the corresponding message. We canreturn
a call to theconfirm
function that has a single string argument containing the correct message.
For fear
levels less than 200
(i.e., fear < 200
):
Fear Level: LOW Still wanna ride?
For fear
levels from 200
through 300
inclusive (i.e., fear >= 200 && fear <= 300
):
Fear Level: MEDIUM Think you'll make it?
Note: You do not need to change the existing code that’s provided for you in the challenge editor.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | var fear = fearGenerated(numPeeps, rainInInches, numSharks); var fearMessage = function() { // Insert conditional statements here if(fear < 200){ return "Fear Level: LOW\n Still wanna ride?"; } else if(fear >= 200 && fear <= 300){ return "Fear Level: MEDIUM\nThink you'll make it?"; } }; function confirmRide(confirmToGo) { return confirmToGo(); } // Call confirmRide with the fearMessage function var startRide = confirmRide(fearMessage); | cs |
'IT > JAVASCRIPT' 카테고리의 다른 글
[Javascript]문제 1.4: Displaying Function Contents (0) | 2018.01.11 |
---|---|
[Javascript]문제 1.3: Using Function Expressions with Parameters (0) | 2018.01.11 |
[Javascript]문제 1.2: Changin Declarations to Expressions (0) | 2018.01.11 |
[Javascript]Function Expressions (0) | 2018.01.11 |