WWDC22 SALE: Save 50% on all my Swift books and bundles! >>

Project 5 Find Bug Challenge

Forums > 100 Days of Swift

I am not able to produce the bug mentioned in the challenge!


Hi Tatzati!

Have you tried doing it like this?:

Choose a word from the one in the title (an anagram). For example, if the word were sandbards, type 'Sand'. Then try adding 'sand' (the first one being uppercased is the important thing). Your app should have accepted both, while it shouln't work like this, as it is exactly the same word. Let me know if u managed to trigger the bug, and if u managed to solve it! Also, let me know if i'm not explaining myself very well as my english is not very good.

Hope it helps!


Change the answer to lowercase using .lowercase even if the person enters in capital letters before checking if the answer is being answered before


So the thing here is that solution to the bug was already provided by Paul on the submit function:

let lowerAnswer = answer.lowercased()

But in the wrap up section he hints that the error should be on:

usedWords.insert(answer, at: 0)

And this is what got me confused.


@tatzati Well, let lowerAnswer = answer.lowercased() creates a constant where answer is always lowercased...

But we have to remember to use lowerAnswer while inserting the new submission (answer) into the usedWords array.

Just did this today! ;)


@ageDiMasi, oh i see now. I had added the lowercassed version to the insert method so that is why i couldn't reproduce the bug :)



Solution for the problem:

userWords.insert(answer.lowercased(), at: 0)



Just to add another view, I think also the code below can work fine, leaving freedom to the user to use whichever case they want to use, while maintaining the logic of the game intact.

func isOriginal(word: String) -> Bool {

    let lowercaseArray = usedWords.map{$0.lowercased()}
    return !lowercaseArray.contains(word)


I am not sure if it is efficient or not, so I am also looking for another opinion, but it works :D


Hacking with Swift is sponsored by Emerge

SPONSORED Why are Swift reference types bad for app startup time, and what’s the performance cost of protocol conformances? That’s just a couple of the topics you can learn about on the Emerge blog — written by the app performance experts behind Emerge’s advanced app optimization and monitoring tools, based on their experience of working at companies like Apple, Airbnb, Snap, and Spotify.

Find out more

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

Unknown user

You are not logged in

Log in or create account

Link copied to your pasteboard.