score:1

Accepted answer

With multiple lines of code, your arrow function needs curly braces

d3.json(url).then(function(data) {
    for (let i = 0; i < data.data.length; i++) arr[i] = data.data[i];
    }).then(() => {

      yScale = d3.scaleLinear()
                 .domain([0, d3.max(arr, (d) => d[1])])
                 .range([460, 0]);

    svg.selectAll('rect')
    .data(arr)
    .enter()
    .append('rect')
    .attr('fill', 'blue')
    .attr('height', d => d[1])
    .attr('width', 3)
    .attr('x', (d, i) => 4 * i)
    .attr('y', (d, i) => yScale(d[1]))

   });

Related Query

More Query from same tag