Preview:
 const courseData = (e) => {
        const { currentTarget } = e;
        // get all the dataset information
        const name = currentTarget?.dataset?.name ?? "";
        const id = currentTarget?.dataset?.code ?? "";
        const funded = currentTarget?.dataset?.funded ?? "";
        const demand = currentTarget?.dataset?.demand ?? "";
        const mode = currentTarget?.dataset?.mode ?? "";
        const options = currentTarget?.dataset?.training ?? "";

        // create object from the current course clicked dataset attributes above
        const course = {
            courseName: name,
            courseId: id,
            funding: funded,
            demand: demand,
            delivery: mode,
            training: options,
        };

        return course;
    };


//or

 function getListData(data) {
        if (!data) return [];
        // console.log(data);
        return data?.map((item) => ({
            name: item?.name ?? "",
            category: item?.category ?? "",
            web: item?.website ?? "",
            tel: item?.tel ?? "",
            email: item?.email ?? "",
        }));
    }

getListData(items);
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter