Periodic Table Database - Build a Periodic Table Database

Tell us what’s happening:

I cannot get the “If the argument input to your element.sh script doesn’t exist as an atomic_number, symbol, or name in the database, the only output should be I could not find that element in the database.” requirement to pass even though that’s the output I get when I run the script in the terminal.

Your code so far

Code Link: Periodic-Table-Database/element.sh at main · UnicornTowel314/Periodic-Table-Database · GitHub

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 OPR/114.0.0.0

Challenge Information:

Periodic Table Database - Build a Periodic Table Database

Welcome to the forum @sarahmckee714

What is the output for?:

  • s
  • water
  • 1000
  • a1b2

Happy coding

Thank you so much. I feel a little silly for forgetting to catch cases like those.

1 Like

my code stuck at this too, and I have revised it 2 times from scratch so just copied someone else’s code which passed even with a test case with “Hel”.
I was sad and just ended up copying it :frowning:
I hope you find the corrections to your code. :slight_smile:

I have this script which passed all user stories EXCEPT this one.
element_script

From what I can tell, we had a similar issue.

So, for anyone getting stuck at these cases, I’d like to share the question I asked myself that gave me my AHA moment.

In an if-else statement, how do you catch conditions that you aren’t explicitly checking for?

1 Like

Thanks, I will surely use this approach more often.

Although, I found that the main culprit was the “exit 1” status in the if-conditions as it was returning 2 responses, the message and the status, which apparently freecodecamp didn’t liked. :laughing: