Bash Scripting Course

Tell us what’s happening:

I am getting this error:

“Your script should have the suggests “if” statement added correctly”

I am on this level:

Awesome. One last thing. Add an empty line in front of where you print the response.

1. Change the existing echo ${RESPONSES[$N]} line

2. Use the -e flag and the new line (\n) character with the echo statement

3. Make sure to use quotes so it prints the new line

4. Run the script and see if it’s working

5. The suggested command should look like this: echo -e "\n${RESPONSES[$N]}"

Your code so far

#!/bin/bash
#Program to tell a persons fortune
echo -e "\n~~ Fortune Teller ~~\n"
RESPONSES=("Yes" "No" "Maybe" "Outlook good" "Don't count on it" "Ask again later")
N=$(( RANDOM % 6 ))
echo -e "\n${RESPONSES[$N]}"

GET_FORTUNE(){
  if [[ ! $1 ]]
  then
    echo Ask a yes or no question:
  else
    echo Try again. Make sure it ends with a question mark:
  fi
  read QUESTION
}
GET_FORTUNE
until [[ $QUESTION =~ \?$ ]]
do
GET_FORTUNE again
done

Lesson URL (https://raw.githubusercontent.com/freeCodeCamp/learn-bash-scripting-by-building-five-programs/main/tutorial.json)

Welcome to the forum @harshdeep2k193840

Shouldn’t the response print after the GET_FORTUNE function has run?

Press the Reset button and try again.

If you are still experience problems, share a screen grab of the terminal after resetting.

Happy coding

hi i have another issue posted can you please look into that one as well

remove the “echo -e “\n${RESPONSES[$N]}””
and add
“echo
echo ${RESPONSES[$N]}”

in the end of your code