Skip to the content.

Fall 2024 - P4

Lesson 3.4 Strings Hack

Popcorn Hack #7 (5%)


Get the lyrics of a clean song to:

  • find how many times the title of the song appears in the lyrics
  • find the index of the 50th word
  • replace the first verse with the last verse
  • concat two verses together to make your own song



Popcorn hack #8 (5%)

  • Using JS:
    • concat a flower with an animal to make a new creature
      • use both quotes and backtick/ template literal to display this
    • set the new creature as a variable
    • write a short story about your creature using variables, multiple lines, dialog, and apostrophes. You can use either quotes or backtick

Main strings hack (20%)

Using sections above…

  1. Make a text analyzer with strings that accepts input from the user
    • Takes multiple words/ sentences
    • Displays original string
    • Counts total characters (includes spaces)
    • Displays longest word with how many characters it has
    • Displays the string reversed
    • Find middle word/ character (excludes spaces or special characters)
    • Correctly displays everything!
  2. Other criteria:
    • make sure program can process upper/lowercase letters, numbers, and symbols
    • Customize and add your own unique function
    • Try to use both python and js, either making two separate analyzers or using both at the same time
  3. Extra/ Bonus: make two additional input systems where user can replace words of the original input.
    • The first input is which word they want to replace, the second is what to replace it with
    • For example, if they inputed a song verse, through the second input they can replace a specific word that repeats in the song with another
    • Make sure input can handle requests to change things that aren’t in original string.

Submit homework here.