Please help, I don't know what I'm doing wrong- d3 line chart javascript

I was trying to create a line chart using d3 as shown here:

Pretty new to coding and have been completely stuck on where I am going wrong, google and youtube didn’t seem to have the answer either. My issue is with plotting data from a downloadable json. The rest of the code was tested with dummy data and seems to work. Here is the relevant portion:

   // Parse the date / time
    var parseDate = d3.time.format("%y%m%d").parse;

   // Create a request variable and assign a new XMLHttpRequest object to it.
        var request = new XMLHttpRequest()

        // Open a new connection, using the GET request on the URL endpoint
        request.open('GET', url, true)
        request.onload = function () {
            // Begin accessing JSON data here
            var data = JSON.parse(this.response)
            let dataY = []
            let dataX = []

                    let i = 0;
            data.reverse().forEach((dataset) => {
                //    console.log(dataset.values)
                dataY[i] = dataset.values;
                dataX[i] = dataset.date;
                i++;
            })

So this gets my data as my X dates and my Y values, and creates an array for the values of each. This works without error. Any time I try to take this further though, I run into errors.

I tried

function (d) { return { date: d3.timeParse("%Y%m%d")(d.dataX), value: d.dataY } },

I tried

function parseData(data){
            var arr = []
            for (var i in dataY.length()){
                arr.push({
                    date: new dataX[i],
                    value : dataY[i]
                }

                )
            return arr;
            }

        }

And lots of other stuff. Any help is super appreciated.

And I am happy to provide any further info needed!

Edit: I just realized that the page I saw this lesson on might have been a poster and not the official curriculum, if I should post this somewhere else, just let me know.  Sorry!

Can you provide us the error?

Moreover it would be awesome to see a (not) working example, you can use:


Hello,

Thank you very much for the reply, I really appreciate it!

Sorry, I am happy to post the full script. Very very new to coding and just wasn’t even sure the proper way to ask questions like this :). I really appreciate the help!

Attempt 1: https://pastebin.com/4LS1XiB5

Attempt 2: https://pastebin.com/rJ9EdKjw

This is my code. I can move it to CodePen if you’d prefer! As a project to understand js better, I was hoping to recreate the “new cases” curve seen on covidtracking. com for New Jersey. I may have chosen too ambitious of a starting project, but any insight you can provide is incredibly appreciated. I am also happy to answer any questions!

Moving it to codepen would be awesome, so we could play around with it and test stuff!