Lodash Project

I’m in the process of working through the Lodash project (Linked HERE) and keep getting an error in testing due to a Syntax error with inRange (the section in italic/bold in code below). Is there something I’m missing in terms of a bracket, semicolon or otherwise? My code so far is below:

const _ = {
clamp(number, lower, upper){
var lowerClampedValue = Math.max(number,lower);
var clampedValue = Math.min(lowerClampedValue, upper);
return clampedValue;
}

inRange(number, start, end){
if (end === undefined){
end = start
start = 0
} if (start > end) {
var temp = end
end = start
start = temp
}
var isInRange = start <= number && number < end
return isInRange
}

words(string){
var words = string.split(’ ');
return words;
}

};
// Do not write or modify code below this line.
module.exports = _;

It looks like you’re missing commas between your methods. You’re building an object, so you still need the commas, even if you’re adding methods instead of standard properties. If you were using Class syntax, then the commas wouldn’t be necessary.

const example = {
  message: 'I can still add standard object properties too',

  test() {
    console.log('Fancy method');
  },

  test2() {
    console.log('Fancier method');
  },

  test3() {
    console.log(this.message);
  }

};

Thanks! Far more clear now in that case

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