Description
Instructions
Read:
Optional: Eloquent Javascript, Chapter 3.
Lab:
Create a calculator script. It should:
1. Prompt the user for two numbers.
2. Prompt the user for the operator that they would like to use … addition, multiplication, division.
3. Pass the two numbers and the operator into a function
3. Perform the calculation – use an IF or SWITCH statement to perform the operation
4. Display the results either as an alert, using document.write, or in the console.log.
Due Sunday, Feb 27th, 11:59 p.m.
Small Group Forum Work:
In your small group, propose how you could add a function to the program.
This means that the weather application should contain an array, a loop, a branching statement and a function.
For example, you could use a function to prompt the user for input, or a function that can perform a calculation of some sort (i.e. Fahrenheit to Celsius). This is up to your group.
Hide Assignment Information
Instructions
Assignment: Prepare for the Mid-term
- Next week you will have a mid-term. The mid-term is “open book” and you will have three hours to complete it, starting when you first access it.
The questions in the mid-term will draw from everything we’ve covered in class up until now. The best way to prepare is to go back through the lessons and assignments, as well as the solutions posted to the lab assignments.
In order to practice for the exam, there are two programming challenges.
There is also a forum called “Mid-Term Practice Questions” placed under the general course forums. Use this space to ask questions about the mid-term and the practice exercises.
Practice Exercises
Here are a few practice question for you to use for practice for the mid-term. If you have questions, please post them under the General Class Forums to the “Mid-Term Practice Questions” forum.
Exercise 1:
Step 1. Create a function that takes in a word from the user (prompt the user).
Step 2. reverse the word and display it back to the user
Exercise 1:
You can create a random number using the following:
var randomNumber = Math.floor(Math.random()*10)+1
This create a random number between one and ten. Change the “10” to “12” and you create a random number between 1 and 12. Make sense?
Write a program that prompts the user for a number.
Then, generate a random number between 1 and 10, and multiple the users number with this new number that you just created.
Output the new number you created by multiplying the user number and your random number to user using a prompt and ask them what they think your random number is.
Evaluate the user input. If they are right, indicate that in an alert. If they are wrong, indicate that and provide the correct answer in an alert.
Exercise 3:
1.Create a ‘Cookbook’ program: it can contain recipes for anything.
2. Prompt the user for a recipe name, then for at least three ingredients.
3. Use a multidimensional (jagged) array to store this information.
4. When the user is done adding items, print out the recipe names and ingredients to the console.
Hide Assignment InformationINSTRUCTIONSASSIGNMENT: PREPARE FOR THE MID-TERMNext week you will have a mid-term. The mid-term is “open book” and you will have three hours to complete it, starting when you first access it.The questions in the mid-term will draw from everything we’ve covered in class up until now. The best way to prepare is to go back through the lessons and assignments, as well as the solutions posted to the lab assignments.In order to practice for the exam, there are two programming challenges.There is also a forum called “Mid-Term Practice Questions” placed under the general course forums. Use this space to ask questions about the mid-term and the practice exercises.Practice ExercisesHere are a few practice question for you to use for practice for the mid-term. If you have questions, please post them under the General Class Forums to the “Mid-Term Practice Questions” forum.Exercise 1:Step 1. Create a function that takes in a word from the user (prompt the user).Step 2. reverse the word and display it back to the userExercise 1:You can create a random number using the following:var randomNumber = Math.floor(Math.random()*10)+1This create a random number between one and ten. Change the “10” to “12” and you create a random number between 1 and 12. Make sense?Write a program that prompts the user for a number.Then, generate a random number between 1 and 10, and multiple the users number with this new number that you just created.Output the new number you created by multiplying the user number and your random number to user using a prompt and ask them what they think your random number is.Evaluate the user input. If they are right, indicate that in an alert. If they are wrong, indicate that and provide the correct answer in an alert.Exercise 3:1.Create a ‘Cookbook’ program: it can contain recipes for anything.2. Prompt the user for a recipe name, then for at least three ingredients. 3. Use a multidimensional (jagged) array to store this information.4. When the user is done adding items, print out the recipe names and ingredients to the console.