Conditional Statements

Hello, can someone help explain this basic problem on conditional statements? It is a problem from a quiz section. I did not quite understand the answer when first was presented to me to solve. Then the second time I already knew the answers because the first time was wrong.

Here is a link to the problem as well. Thank you.

What will the code block log to the console?

let runTime = 35;
let runDistance = 3.5;

if (runTime <= 30 && runDistance > 3.5) {
console.log(“You’re super fast!”);
} else if (runTime >= 30 && runDistance <= 3) {
console.log(“You’re not making your pace!”);
} else if (runTime > 30 || runDistance > 3) {
console.log(“Nice workout!”);
} else {
console.log(“Keep on running!”);

1 Like

Let’s see. In each condition we are checking both the runTime and the runDistance.

First, we check if the runTime is less or equal to 30 and the runDistance is bigger than 3.5. If those conditions are both true, we log “You’re super fast!”.

And now, what if the runTime is bigger than or equal to 30 and the runDistance is less than or equal to 3? Then we would log “You’re not making your pace!”.

Now, what if, the runTime was bigger than 30 or the runDistance was bigger than 3? Then we would log “Nice workout!”.

And in every other possible case, we’ll log “Keep on running!”.

In this case, the values of our variables would fall into the third condition, therefore we would log “Nice workout!”.

Hope this helped :slightly_smiling_face:

1 Like

Thank you. It did helped. I looked at this problem a second time and able to understand it better. Have you been in the focus sessions ? students meet Wednesday and Fridays at 12noon pacific time for web development. I am planing to join Wed. It is over zoom meetings.

1 Like

Glad I could help :slight_smile:

Nope, and I have never been in a zoom meeting before lol. I would have to show my face, right? I’m not very comfortable with that idea :laughing: Also, 12PM Pacific isn’t much of a good time for me where I live lol.

But I hope you have fun! :upside_down_face:

Are you familiar with functions? I got this one from the JS practice.

Which of the following is NOT a properly written arrow function?

let nameLogger = (name) => { console.log(Hi, my name is ${name}.); }

let phraseSplit = phrase => phrase.split(" ")

let multiply = (x, y) => x * y

let fileName = function(x) => console.log(File name is ${x});

No worries.
What country are you located ?

Yep, I am. It’s the last one, right? The last one is not a properly written arrow function (cause you don’t need to use the function keyword with arrow functions).

I live in Mexico. (It looks like my post must be at least 20 characters so yeah :stuck_out_tongue:)

Yes, you are right. I got it wrong 2 times from the practice. I am studying functions now. The helper functions is confusing now. Not getting it yet.

Amazing. I grew up in Mexico. In the state of Michoacan but moved to the US when I was a teenager. Are you Mexican or other Nationality but living in Mexico? When I was in primary school in Michoacan I had some classmates kids who were Americans(white).

Helper functions are basically just functions you call inside another function. They help break big tasks into chunks, so you don’t need to have a BIIIIG function that does the full task. Instead you have many smaller functions that you can call inside one another, and that makes your code way more manageable.

Hope that helped :upside_down_face:

Woah that’s such a cool coincidence lol :open_mouth:
Nah, I am Mexican. And as a fun fact, I have never traveled to any other country :sob: And now, I’m not sure I ever will :neutral_face:

Hi, how have you been? I can’t believe is has been 7 days since we last talked. I kind of slowed down with my studying here. Been kind of tired and busy.

1 Like

Hiii! It’s been 7 days? Dang.
I’ve been great, I’m getting vacations next week (if I pass my exams) so I’ve been trying to make an activities planner for my 1-week vacations. Which I’ll be spending at home lol :sweat_smile:

Aw that sucks :confused: I hate being tired…but I’m tired most of my life :yawning_face: :stuck_out_tongue:

How was your vacation? staycation in other words. I have a question about codecademy. Do you know if the people in the forums who help with questions are all students ? Is there any teacher support on the forums to help with questions?

Hi! It was great, I really enjoyed it. I improved so much with my art.

Hmm…well, I do know @mtf is not a student, and he knows a lot of stuff. But other than that I’m not sure honestly.

A good many of the learners are still in school right up to college and university. Technically we’re all students of coding.

No, there are no teachers, as such. We’re all volunteers with the same basic aim… Learn to code and help guide others while we maintain the forums. CC does have teachers on staff but their roles are curriculum based.


Thank you for your reply.