Part 11: AND


#1

The console shows " Oh i see; Oh i see; A hungry man is an angry man!"
What am i doing that causes it to do that? So far what i want to happen is to just print "a hungry man is an angry man!"


// Declare your variables here!
var hungry=true
var foodHere=true

var eat = function() {
  // Add your if/else statement here!
  if(hungry && foodHere){
    console.log("A hungry man is an angry man!")
    return true
  }
  else{
    console.log("Oh i see")
    return false
  }
  
};


#2

If you want to something specific to print to the console, call your eat function or use a console.log statement to call the eat function.


#3

ok so to get it to just say "a hungry man is an angry man!", basically, call the function, alrighty

but what makes it print "oh i see; oh i see; a hungry man is an angry man!" ?


#4

I think it has something to do with the console display codecademy uses. I've read on the forums that it repeats the last line of code. Have you ever noticed that it displays the word 'false' sometimes even if you haven't logged anything to the console?

On repli.it, your code displays nothing:

https://repl.it/CbDu

On jsbin:

http://jsbin.com/zunozakece/edit?js,console


#5

Your missing semicolons?.


#6

oh ok... But semicolons do not cause these sort of things
this is because semicolons are they to tell the console to continue running the code in a way


#7

What are you trying to do exactly?


#8

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