Return Home

Q: 1. Write a JavaScript statement that declares an array named oceans with eleven elements.
Q: 2. Write a JavaScript statement that writes the value of the fifth element of the array declared in question 1 to the current document.
Q: 3. Write a JavaScript statement that declares an array named cats and initializes it with an array literal containing the following values: “Yvette”,”Felix”, “Fluffy”, “Joey”, “Snowball”, “Mousie”.
Q: 4. Write a function that returns the larger of its two arguments. For example, the call larger(-2, 10) should return 10.
Q: 5. Write a JavaScript statement that calls the greet() function so that it writes the following into the current document.
Q: 6. Write a function named calcAreaTriangle that has two parameters, base and height, and returns the area of a triangle with those dimensions.
Q: 7. Given: var myQuote="He who laughs, lasts."; Give the value of each of the following expressions:
a. myQuote.toUpperCase() =
b. myQuote.indexOf("a") =
c. myQuote.indexOf("@", 1) =
d. myQuote.indexOf("who") =
e. myQuote.indexOf("a", 10) =
f. myQuote.lastIndexOf("a") =
g. myQuote.lastIndexOf("a", 7) =
h. myQuote.lastIndexOf("a", 10) =
i. myQuote.charAt(7) =
j. myQuote.charAt(myQuote.length) =
k. myQuote.charAt(myQuote.length - 3) =
Q: 8. Write a conditional expression that evaluates to “happy” if mouthCurve is less than 180 and “sad” if mouthCurve is greater than or equal to 180.
Q: 9. Write a script that prompts the user for a string, then alerts whether or not the input string is a palindrome.