const letters = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","_"];
$.each(letters, (number, letter) => {
let b = $('<button>');
b.addClass('letter-button letter letter-button-color')
.attr('data-let', letter)
.text(letter);
$('#buttons').append(b);
});
$('.letter-button').on('click', () => {
let fridgeMagnet = $('<div>');
fridgeMagnet.addClass('letter fridge-color')
.text($(this).data('let'));
console.log(this);
$('#display').append(fridgeMagnet);
});
This is an old exercise and the solution is with the outdated version of JavaScript. I am trying to update step 4 and 5 to ES6, but $(this) is not working here. Can anyone explain to me how to fix the click handler and how $(this) changes from ES5 to ES6? We want the newly created buttons to appear on the backround fridge image with the correct letter data. Also, what is 'data-let'?