Conversation
f4c9c7a to
7c63bab
Compare
Skfnrj
left a comment
There was a problem hiding this comment.
Nice work, the script is easy to follow and I like how you used arrays for the questions and answers. The case-insensitive check is also a nice touch.
Maybe you could also handle small variations in answers (like “the sky is blue”), but overall it looks good and works well.
|
This is nice, I like how you handled the answers with lowercase so it’s more flexible |
IvoPetrevski
left a comment
There was a problem hiding this comment.
The logic for answering questions works without any problems. I think it would be better if you use an associative array. It would make it easier to track and add new questions and the array will be in a different order every time the script is executed. This would make the trivia game a bit more exciting.
| @@ -0,0 +1,41 @@ | |||
| #!/bin/bash | |||
|
|
|||
| questions=( | |||
There was a problem hiding this comment.
this works, but it might be more readable to use a associative array.
|
|
||
| # convert both to lowercase + remove extra spaces | ||
| user_answer=$(echo "$answer" | xargs | tr '[:upper:]' '[:lower:]') | ||
| correct_answer=$(echo "${answers[$i]}" | tr '[:upper:]' '[:lower:]') |
There was a problem hiding this comment.
good data normalization on both sides
Closes #7
This PR adds a trivia game: