Two questions - Code your own Adventure


#1

Please help me write a code that satisfies the following conditions:
1. During User Response to "Do you want to race Bieber on stage?",response should be case insensitive. That is Yes, yes, or yEs should be acceptable.
I tried the following code with no luck!
if (userAnswer === "Yes" | "yes")
2. While receiving the Rating response from the user, how to ensure that the response is a number and that too less than or equal to 10?


#2

Here are some hints:

  1. Case doesn't matter. So, "yes", "YES", "yEs", "YeS" etc. can be changed to some other case. That is user input's case can be changed to either lower or upper. You must be knowing of the two built-in methods that let you do this. Change the user's input's case, and compare it with "YES" or "yes" depending on whether you changed the case to upper or lower respectively.
  2. typeof operator generates a string that will help you identify whether it's a number of any other type. Example, typeof true gives "boolean". typeof 3 gives "number". Also, for the second part ("less than or equal to 10") you have to use a relational operator. Construct an if condition using both these two parts.

Hope it helps!


#3

@sureshdev,

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLowerCase

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_Operators

https://developer.mozilla.org/nl/docs/Web/JavaScript/Reference/Operators/typeof

https://developer.mozilla.org/nl/docs/Web/JavaScript/Reference/Operatoren

Reference

google search
== the Book ==
javascript [your question] site:developer.mozilla.org

== discussions / opinions ==
javascript [your question] site:stackoverflow.com

== guidance ==
www.crockford.com
http://javascript.crockford.com/code.html
http://javascript.crockford.com/survey.html
http://stackoverflow.com/questions/9549780/what-does-this-symbol-mean-in-javascript
https://developer.mozilla.org/en-US/docs/Web/JavaScript/A_re-introduction_to_JavaScript
www.developer.mozilla.org/en-US/docs/Web/JavaScript/Guide
http://stackoverflow.com/questions/336859/var-functionname-function-vs-function-functionname?rq=1


#4

@gaurangtandon
@leonhard_wettengmx_n
Thanks for your help - I got the required info that is required to satisfy my conditions!