# Unit 6 Lesson 6 part 7a (customer review) incorrect

**URL:** <https://forum.code.org/t/unit-6-lesson-6-part-7a-customer-review-incorrect/39161>\
**Category:** Coding and Debugging Help\
**Created:** [March 18, 2024, 9:01pm UTC](https://forum.code.org/t/unit-6-lesson-6-part-7a-customer-review-incorrect/39161 "2024-03-18T21:01:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tsinnott](https://avatars.discourse-cdn.com/v4/letter/t/b5ac83/32.png) [@tsinnott](https://forum.code.org/u/tsinnott)\
**Post date:** [March 18, 2024, 9:01pm UTC](https://forum.code.org/t/unit-6-lesson-6-part-7a-customer-review-incorrect/39161/1 "2024-03-18T21:01:55Z")

</div>

The Example solution is incorrect. You should not parse the responses by finding " ". It will fail to match “great” with “great!”. If you run the example solution, it says the word great exists 2 times in the first response, but it actually exists 3 times.  
The suggested algorithm is fundamentally flawed. You should use indexOf() until you get a -1 (chopping the string down each time). It’s easier, less code, and more straightforward.  
EG:

```auto
   ArrayList<Integer> result = new ArrayList<Integer>();
    
    for (String r : reviews)
    {
      int count=0;
      int i = r.indexOf(wordToFind);
      while(i>-1)
      {
            count++;
            r=r.substring(i+1);
            i=r.indexOf(wordToFind);
      }
      result.add(new Integer(count));
    }
    return result;

```

This means that what I think is correct, will not pass the test…or am I missing something?

---

<div class="post-metadata">

**Author:** ![lindsay.davis](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/lindsay.davis/32/7632_2.png) [@lindsay.davis](https://forum.code.org/u/lindsay.davis)\
**Post date:** [March 19, 2024, 12:16am UTC](https://forum.code.org/t/unit-6-lesson-6-part-7a-customer-review-incorrect/39161/2 "2024-03-19T00:16:23Z")

</div>

Hi Timothy, thanks for your post about this lesson! I noticed the same issue as I did this lesson withmy class. I live coded this level with my students and we got it working using the suggested algorithm just checking for the spaces. We then noticed the great! that didn’t get added to the tally and discussed what we would need to look for in terms of punctuation to store just the words and no punctuation, and also considered the use of .toLowerCase() to account for capitalization differences. Some of my students went through and added that functionality as part of their unit 6 projects. The fully working version then doesn’t meet the tests, but also is a much more complicated algorithm. Please use the rate this lesson button on the unit overview page to give your feedback on this to the curriculum team.

Thank you,  
Lindsay

---

<div class="post-metadata">

**Author:** ![tsinnott](https://avatars.discourse-cdn.com/v4/letter/t/b5ac83/32.png) [@tsinnott](https://forum.code.org/u/tsinnott)\
**Post date:** [March 19, 2024, 1:43am UTC](https://forum.code.org/t/unit-6-lesson-6-part-7a-customer-review-incorrect/39161/3 "2024-03-19T01:43:59Z")

</div>

But the correct way is to not break the reply into “words”. You just need to count the number of indexOf (chopping the reply down as I did in my example). It’s actually quite simple (simpler than the example solution). It’s also the standard way it’s done on the AP Test…although there are other functions/methods in the String class that would make this even easier.  
I don’t mind their being issues with [code.org](http://code.org)’s code, but I do take issue with [code.org](http://code.org) encouraging flawed logic. Their algorithm is not correct. That said, I will do as you suggest and use the “rate this lesson”. Thanks.

---

<div class="post-metadata">

**Author:** ![lindsay.davis](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/lindsay.davis/32/7632_2.png) [@lindsay.davis](https://forum.code.org/u/lindsay.davis)\
**Post date:** [March 25, 2024, 3:35pm UTC](https://forum.code.org/t/unit-6-lesson-6-part-7a-customer-review-incorrect/39161/4 "2024-03-25T15:35:53Z")

</div>

Thank you, Timothy for passing that code and your thoughts onto the curriculum team using the rate the lesson button. And for posting here, it gives other teachers who are prepping for this lesson the heads up about this level. This curriculum is improved each year, and teacher feedback like yours is helpful in that endeavor!

Best,  
Lindsay
