o

Javascript Assignment 3

Read chapter 4 in the book. 

For the exercises below, write each task and then show the task with the output answer below it (I just want your work to be well-labeled and clear). 

  1. Write a long sentence and store it into a new string object.
  2. Output the number of characters in the string.
  3. Demonstrate that you can locate the position of a substring inside the string.
  4. Output characters in the string from position 4 to position 9
  5. Create an HTML form with a text entry box. Print a long string (a paragraph) to the screen. Ask the user to enter a word or a phrase that is contained in the paragraph. Can you take the user input and report back a message like: "The search phrase you entered was found at position X in the string".
  6. Working with the form input from task 5 above, can you report back the total number of occurances of the user's phrase? You might look at the split() & loop code on page 80 - that's a good direction. Or you could try creating a regular expression based on user input. On this one, you should probably spend most of your time reading, then you'll be able to figure it out & code it pretty quick. Feel free to turn it in as far as you get it.
  7. Starting with the value of Pi, demonstrate the output of the Math object methods: sin, cos, tan, ceil, floor & round.   You don't need to take any user input.
  8. Starting with a comma separated string like "dog,cat,horse,pig,llama" - split that string into and array and write a loop that outputs each array item on a separate line.