GithubHelp home page GithubHelp logo

malachi-m / peter-piper Goto Github PK

View Code? Open in Web Editor NEW

This project forked from unioncollege-webtech/peter-piper

0.0 1.0 0.0 99 KB

An exercise for inspecting strings using .length and .charAt()

License: ISC License

JavaScript 100.00%

peter-piper's Introduction

Peter Piper Exercise

Join the chat at https://gitter.im/unioncollege-webtech/peter-piper

In this exercise, we count how many times the letter ‘p’ occurs in Peter Piper’s famous tongue twister:

Peter Piper picked a peck of pickled peppers.
A peck of pickled peppers Peter Piper picked.
If Peter Piper picked a peck of pickled peppers,
Where's the peck of pickled peppers Peter Piper picked?

Description

Update file peter-piper.js, adding the correct code to count the number of times a “P” occurs in the Peter Piper tongue twister. Be sure to count both uppercase P and lowercase p characters.

Completing and submitting the assignment

You are also welcome commit, push, and create a pull request before you’ve completed your solution. You can ask questions or request feedback there in your pull request. Just mention @barberboy in your comments to get my attention.

Extra Credit

Want to work a bit harder? Try these variations:

  • Define a function called countOccurrences(string, char), which counts the number of times the character char occurs in the string string, then call it to find the number of p's in the tongue twister, like:
    var counter = countOccurances(peterpiper, 'p');.

  • Instead of looking for the letter 'p', count the number of times the word 'peck' occurs in the tongue twister.

  • Try counting the occurrences of 'p' without using a for loop. Take a look at the other String.prototype methods for ideas.

Use git branch (and git checkout) to work on the extra credit on separate branches.

References

peter-piper's People

Contributors

barberboy avatar gitter-badger avatar malachi-m avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.