Periodic Table DB : test case not passing

If you run ./element.sh , it should output Please provide an element as an argument and finish running.

Here its running fine in the screenshot
I’m really confused when i run it seem to be as test case please help !!!

(Thanks for looking into it)

#! /bin/bash

PSQL="psql --username=freecodecamp --dbname=periodic_table -t --no-align -c"
X=10


DISTINCT(){

MAIN_QUERY="select * from properties inner join elements on properties.atomic_number=elements.atomic_number full join types on properties.type_id=types.type_id"
 

if [[ $1 =~ ^[0-9]+$ ]]
then

  QUR=$($PSQL "$MAIN_QUERY WHERE elements.atomic_number=$1")
  PRINT_INFO $QUR
  
elif [[ $1 =~ ^[a-zA-Z]{1,2}$ ]]
then

  QUR=$($PSQL "$MAIN_QUERY WHERE elements.symbol='$1'")
  PRINT_INFO $QUR

else

  QUR=$($PSQL "$MAIN_QUERY WHERE elements.name='$1'")
  PRINT_INFO $QUR

fi

}

PRINT_INFO(){
  if [[ $1 ]]
  then
  IFS="|"; read AN AM MP BP TID AN SYM N TID TY <<< $1
  INFORMATION $AN $N $SYM $T $AM $MP $BP
  else
    echo -e "\nI could not find that element in the database."
  fi
}

INFORMATION(){
  # 1 atomic number
  # 2 element name
  # 3 atomic symbol
  # 4 type 
  # 5 atomic_mass
  # 6 melting point
  # 7 boiling point
  echo -e "\nThe element with atomic number $1 is $2 ($3). It's a $4, with a mass of $5 amu. $2 has a melting point of $6 celsius and a boiling point of $7 celsius."
}



if [[ $1 ]]
then
  DISTINCT $1
else
  echo -e "\nPlease provide an element as an argument"
fi

There was a recent change to try and clarify that test. There’s supposed to be a period at the end of the sentence. Please provide an element as an argument. It looks like it accidentally got removed with that update.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.