Using Conditionals


#1

I having issues with this portion if the exercise

https://www.codecademy.com/courses/learn-the-command-line/lessons/learn-bash-scripting/exercises/conditionals?action=resume_content_item

#!/bin/bash
first_greeting=“Nice to meet you!”
later_greeting=“How are you?”
greeting_number=1
if [ $greeting_number -lt 1 ]
then
echo $greeting_number
else
echo How are you
fi


#2

Is there a question to go with this topic?


#3

#4

yes see below can’t make it work

#!/bin/bash
first_greeting=“Nice to meet you!”
later_greeting=“How are you?”
greeting_number=1
if [ $greeting_number -lt 1 ]
then
echo $greeting_number
else
echo How are you
fi


#5

I tried different approaches and nothing


#6

Is this a PHP lesson? I thought PHP was dropped from the curriculum?

if (condition)

Note the use of parentheses, not square brackets.


#7

This IS C++
Below is the question
We’ve added two different greetings and a variable to store how many times the user has been greeted before. If this variable is less than 1, we want to use first_greeting . Otherwise, we want to use later_greeting .

Add a line setting up the if conditional. Use the -lt operator.


#8

Please the URL of the exercise page.


#9

https://www.codecademy.com/courses/learn-the-command-line/lessons/learn-bash-scripting/exercises/conditionals?action=resume_content_item


#10

Okay, I’ve reached that lesson and discovered a bug. The provided script has,

greeting_number=1

but the SCT is expecting,

greeting_occasion=1
#!/bin/bash
first_greeting="Nice to meet you!"
later_greeting="How are you?"
greeting_occasion=2
if [ $greeting_occasion -lt 1 ]
then
  echo $first_greeting
else
  echo $later_greeting
fi

#11

#12

Thank you Roy.
I am new at this programming stuff.


#13

You’re welcome. Note also that this is not C++, but Bash Script.