Unable to complete 905.1: Learn Bash Scripting by Building Five Programs

Link: https://www.freecodecamp.org/learn/relational-database/learn-bash-scripting-by-building-five-programs/build-five-programs

The task is as followed:
You used the double square brackets with your if statement in the last program, but you can use the double parenthesis with these operators as well. In your script, create an if statement that uses double parenthesis for the condition. Check if the number variable is less than or equal to 15. If it is, use your two variables to print The next number is, B:<number> .

My Code:


# Bingo Number Generator

echo -e "\n~~ Bingo Number Generator ~~\n"

NUMBER=$(( RANDOM % 75 + 1 ))
TEXT="The next number is, "

echo $NUMBER
if (( NUMBER <= 15 ))
  echo $TEXT B:$NUMBER

Once I save the document or press control+enter I get the following message:

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

I’m not exactly new to bash but I need some help figuring out if I’m the issue or the assignment.

That looks pretty correct @Boiob - I would try getting rid of that extra echo $NUMBER above the if. It may be messing with the test. I think it’s extra anyway.


I am also getting the same error. What should i do?
help me out!!!

Can you share your code and maybe a screen shot @siddharthasapkota03? Or explain what you are seeing or something. The suggestion I gave worked for Boiob, is yours the same issue?

it gives the output : Your script should have the suggested “if” statement added correctly

1 Like

now the issue is fixed . I did it from the beginning.

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