Question: Javascript #1 part 1 Add a throw statement to the processNumbers function that throws the message Found an element that is not a number. if
Javascript
#1 part 1
Add a throw statement to the processNumbers function that throws the message "Found an element that is not a number." if one of the elements in numList is not a number. Hint: The function isNaN() returns true if the parameter is not a number.
code-
function processNumbers(numList) { // Code will be tested with different values of numList var result = 0;
for (var index = 0; index < numList.length; index++) { /* Your solution goes here */ result += numList[index] * 1.3 * index; }
return result; }
-------------------------------------------------------------------------------
#1 part 2
Define a method named roleOf that receives the name of an actor and returns that actor's role. If the actor is not in the movie return "Not in this movie.". Ex: roleOf("Keira Knightley") returns "Elizabeth Swann". Hint: A method may access the object's properties using the keyword this. Ex: this.cast accesses the object's cast property.
code-
var movie = { // Code will be tested with different actors and movies name: "Pirates of the Caribbean: At World's End", director: "Gore Verbinski", composer: "Hans Zimmer", cast: { "Johnny Depp": "Jack Sparrow", "Orlando Bloom": "Will Turner", "Keira Knightley": "Elizabeth Swann", "Geoffrey Rush": "Hector Barbossa" }, roleOf: function(actorName) { /* Your solution goes here */ } };
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
