Comp 416 – Web Programming

University of North Carolina at Chapel Hill

Program Template

Name of program

For each of the following, you should write Javascript functions that work on any input string, but you are not required to test the functions beyond what is presented in the skeleton.

Primitive String Processing

In the following problems, you must use only: == indexing (str[index]), length, charAt() (indexing is usually easier than using charAt). Use console.log() for all output.

  1. Use reverseA(str), reverseB(str), etc.
    • A. Print the string in reverse. Do not change str itself. For example: str = 'cat' prints out as 'tac' (but on 3 separate lines in the console window)
    • B. Modify the parameter, str so that the characters are in reverse order
    • C. Return a new string that is str in reverse order. Do not change str itself.