Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript Object-Oriented JavaScript Getters and Setters Getters

Daven Hietala
Daven Hietala
8,040 Points

SyntaxError: Unexpected token <=

I am attempting to complete this lesson on vs code AND the provided workspace.

Both are giving me the same error.. "SyntaxError: Unexpected token <=" whenever I run node Pet.js in the terminal.

I am not sure why both text editors are unable to recognize the <= symbol.

Has anyone else had this issue?

If so, how did you resolve it?

Here is my code..

class Pet {
  constructor(animal, age, breed, sound) {
    this.animal = animal;
    this.age = age;
    this.breed = breed;
    this.sound = sound;
  }

get activity () {
  const today = new Date();
  const hour = today.getHours();

  if (hour > 8 && <= 20) {
    return 'playing';
  } else {
    return 'sleeping';
  }

} 


  speak() {
    console.log(this.sound);
  }

} 

const ernie = new Pet('dog', 1, 'pug', 'yip yip');
const vera = new Pet('dog', 8, 'border collie', 'woof woof');







console.log(ernie.activity);

1 Answer

You condition is incomplete. It should be:

if (hour > 8 && hour <= 20)