Find & Replace

Error message

  • Deprecated function: implode(): Passing glue string after array is deprecated. Swap the parameters in drupal_get_feeds() (line 394 of /home/chamos77/
  • Deprecated function: The each() function is deprecated. This message will be suppressed on further calls in menu_set_active_trail() (line 2405 of /home/chamos77/

The user enters a phrase and two words, the first word is replaced with the second word.

Below in the code example you can see the most basic tests written for this project. BDD or behavior-driven development is a fantastic process for building your application piece by piece.

In the first step we confirm that we return a string since that is the most basic and universal bit of information. In the second test, we look for a more specific string to be return.

code highlight: 
    it("intputs a phrase, and two words and replace the first with the second word", function() {
        expect(findReplace('hello world', 'hello', 'goodbye')).to.equal('goodbye world');

    it("handles common punctution correctly", function() {
        expect(findReplace('Hello, world!', 'Hello', 'Goodbye')).to.equal('Goodbye, world!');

See the Pen Find and Replace by charlie (@CharlesAMoss) on CodePen.