MIS Final Exam

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

45 (10*4.5)

After 10 minutes, how many calories have you burned? function displayCaloriesBurned( ) { /////////////////////////// for (let i=10; i <=30; i=i+5) alert ( ' ln ' + i + ' minutes, you will have burned ' + i*4.5 + ' calories ' );

135 (30*4.5)

After 30 minutes, how many calories have you burned? function displayCaloriesBurned( ) { /////////////////////////// for (let i=10; i <=30; i=i+5) alert ( ' ln ' + i + ' minutes, you will have burned ' + i*4.5 + ' calories ' );

true or false

Boolean expressions evaluate to...

50 (10*5) 127.5 (85*1.5) 108 (12*9) 882 (42*21)

The following code will display multiple distances, what are they? function showDistance (speed, time){ alert (speed*time); } showDistance (10, 5); showDistance (85, 1.5); showDistance (12, 9); showDistance (42, 21);

$2577 (3*859)

The following program is called TuitionCost.html and displays the cost of tuition for a semester when passed the number of credits a student is taking that semester. Using TuitionCost.html program, how much does a student pay when they register for one 3 credit course? function tuitionCost (numberOfCreditsTaken) { if (numberOfCreditsTaken < 0) { return 'Error: Credits cannot be a negative number.'; } else if (numberOfCreditsTaken < 12) { return numberOfCreditsTaken * 859; } else if (numberOfCreditsTaken <= 18) { return 10308; } else { return (10308 + 573 * (numberOfCreditsTaken - 18)); }

functions

allows code to be more maintainable and reusable

$120 (100*1.20)

What is displayed by the following code when passed the value of 100? function calculateTotalWithTip (orderTotal){ return orderTotal * 1.20; } let costOfMeal = parseFloat (prompt('How much is the bill at the restaurant?')); let tipPercentage = .18; alert ('The total payment to the restaurant is " + calculateTotalWithTip (costOfMeal));

19 (2 + 3 * 4 + 3 + 2; 2 + 12 + 5)

What is displayed by the following code? function performCalculation (x, y, z){ return x + y * z + y + x; } let firstValue = 2; let secondValue = 3; let thirdValue = 4;

No. You are not speeding. What's wrong with you?

What is the answer for if amISpeeding(53) is called? let speedLimit = 55; function amISpeeding(speed) { if (speed >= speedLimit) { alert ("Yes, You are speeding. "); } else { alert (No, You are not speeding. What's wrong with you?"); } } amISpeeding(53); amISpeeding(72);

if (somethingIsTrue) { doSomething; } else { doSomethingDifferent; }

What is the basic syntax of if/else if statements?

a function that gets called to check if something is or is not a number

What is the purpose of isNaN?

allows you to send data back to whatever called your function in the first place

What is the purpose of the return keyword in functions?

16 (320 ÷ 20)

What is your MPG if you have driven 320 miles and used 20 Gallons of gas? (analyze the code) function calculateMPG(miles, gas) { return miles/gas;

while Loop

What loop do we use when we don't know the specific number of times?

for Loop

What loop do we use when we want the code to run a specific number of times?

variable name cannot begin with a number

What's wrong with the statement listed below? let 365days= = prompt ("How many days are in a year?");

HTML

Which coding language is all about displaying content?

CSS

Which coding language is all about making content look good?

JavaScript

Which of the following technologies are used to add interactivity to your site?

allows you to run code based on whether a condition is true or false

Why do we use if/else statements?

loops allow you to specify the code you want to repeat and a way to stop the repetition when a condition is met

Why do we use loops?

it waits for the user to do something and then executes code

Why is JavaScript event-driven?

if statement checks a condition and executes a set of statements when this condition is true, it does not do anything when the condition is false. if-else statement checks a condition and executes a set of statements when this condition is true, it executes another set of statements when the condition is false.

How are if statements different then else-if and else?

if the first expression and the second expression both evaluate to true

How do we evaluate conditions if we have &&?

if either the first expression or the second expression both evaluate to false

How do we evaluate conditions if we have ||?

7, 180 (10+5+5+5+5+5+5+5; 40*4.5)

If we change i<=30 to i<=40 how many times does the function run and how many total calories are burned? function displayCaloriesBurned( ) { /////////////////////////// for (let i=10; i <=30; i=i+5) alert ( ' ln ' + i + ' minutes, you will have burned ' + i*4.5 + ' calories ' );

3, 135 (20+5+5+5=30; 30*4.5)

If we change the initial value of i to 20 how many times does the function run and how many total calories are burned? function displayCaloriesBurned( ) { /////////////////////////// for (let i=10; i <=30; i=i+5) alert ( ' ln ' + i + ' minutes, you will have burned ' + i*4.5 + ' calories ' );

it invokes the code to run (wakes our function up and makes it do things)

What does calling a function do?

your function call contains some data that you pass into the function, it takes what as known as an argument for figuring out what to actually display when it gets called

What does it mean to pass a function arguments, and what does that do?

a way to organize your code to make it easier to create, maintain, and reuse

What is a function in JavaScript?

false (you can start with any number and go up to any number)

True or False? A loop cannot start with a negative number? - Refer to example below: for (let i = -10; i <= 30; i=I+5) {

93 i = 13 13 <= 18 0+13=13 i = 14 14 <= 18 13+14=27 i = 15 15 <= 18 27+15=42 i = 16 16 <= 18 42+16=58 i = 17 17 <= 18 58+17=75 i = 18 18 <= 18 75+18=93

Using the program myFunction.html, what is displayed when you pass 13 as the first number and 18 as the last number? function myNumber (firstNumber, secondNumber) { let valueToReturn = 0; for (let i = firstNumber; i<= secondNumber; i++) { valueToReturn = valueToReturn + i; } return valueToReturn; } let firstNumber = parseInt (prompt("What is the first number?')); let secondNumber = parseInt (prompt("What is the second number?")); alert (myNumber(firstNumber, secondNumber));

18 i = 18 18 <= 18 0+18=18

Using the program myFunction.html, what is displayed when you pass 18 as the first number and 18 as the last number? function myNumber (firstNumber, secondNumber) { let valueToReturn = 0; for (let i = firstNumber; i<= secondNumber; i++) { valueToReturn = valueToReturn + i; } return valueToReturn; } let firstNumber = parseInt (prompt("What is the first number?')); let secondNumber = parseInt (prompt("What is the second number?")); alert (myNumber(firstNumber, secondNumber));

values

Variables are identifiers for what?

the starting point the step the condition

What are the three parts of a for loop?

- any length as long as they don't start with a number and do not contain spaces - they can start with: a letter, underscore, or the $ character

What can variables be named?

- name - are passed with zero or more pieces of information - return a value (usually)

What do all functions have?


Set pelajaran terkait

Lit Final Study Guide (7th Grade)

View Set

BYU Fitness For Living Unit 1, BYU Fitness for Living Unit 2, BYU Fitness for Living Unit 3, BYU Fitness for Living Unit 4, BYU Fitness for Living Unit 6, BYU Fitness for Living Unit 7

View Set

PrepU Management of Patients with Chest and Lower Respiratory Tract Disorders

View Set

BCOR350 Ch 12 Marketing Channels

View Set

Chapter 4: Hardware and Software

View Set