ES6 and the "Make a person" challenge. Issue with "let"

Hello! I have a question regarding ES6 and FCC.

In the “Make a person” challenge, I tried implementing the ES6 syntax. The code would not work if I used “let” to declare the “Person” creator or the “Bob” instance.

Is it an issue with my code? Otherwise, is it an issue with browser compatibility (I use up to date Chrome) or FCC compatibility? If so, should I not use ES6 on FCC?

Below is my solution with the two “var”


//jshint esversion:6
var Person = function(firstAndLast) {
    // Complete the method below and implement the others similarly
  this.getFirstName = () => firstAndLast.split(" ")[0];
  this.getLastName = () => firstAndLast.split(" ")[1];
  this.getFullName = () => firstAndLast;
  this.setFirstName = (first) => firstAndLast = first + " " + firstAndLast.split(" ")[1];
  this.setLastName = (last) => firstAndLast = firstAndLast.split(" ")[0] + " " + last;
  this.setFullName = (changed) => firstAndLast = changed;

var bob = new Person('Bob Ross');

let cannot work for this exercise because of the way the code is reevaluated for each test - both declarations are global - var can be used to redeclare a variable in the same scope but let cannot

1 Like