Exercises 03



Using the ASCII Values of characters part 2

Note that alphabet[4].charCodeAt() gives the ascii value of the 5th element of the string called alphabet

Note that String.fromCharCode(65) gives the letter "A"

  1. Set a string variable in lowercase letters and write a function called countASCIIOver100()to count how many characters' ascii values are above 100.
    E.g. if the variable was set to “Many are the commas in autumn ” the console should show:
    The number of a characters with ASCII over 100 is: 19


  2. Adapt the function from Q1 and generalise it so that it also takes the ASCII value that you want to test as a parameter as well as the string.

  3. Set a string variable and write a function called countWords()to return the total number of words in the string
    E.g. if the variable was set to “Many are the commas in autumn” the console should show:
    The number of a words are: 6




Running the Functions

Provide evidence of your code running Exercise 1 here:

Provide evidence of your code running Exercise 2 here:

Provide evidence of your code running Exercise 3 here: