---
title: "Comment by Favourite Jome on \"Urgent 2k for JavaScript Developers\" | Hashnode"
description: "This is really an interesting challenge, it did take some thinking. so here&#39;s my answer. const studentsData = async function ( ) { const allStudent = await"
url: "https://hashnode.com/posts/urgent-2k-for-javascript-developers/61685e0353401f641ba16faa/comment/6168b2ce53401f641ba1755f"
---

[Discussion](https://hashnode.com/posts/urgent-2k-for-javascript-developers/61685e0353401f641ba16faa)

Comment [Urgent 2k for JavaScript Developers](https://hashnode.com/posts/urgent-2k-for-javascript-developers/61685e0353401f641ba16faa)

[Favourite Jome](https://hashnode.com/@Favourite)

[Oct 14, 2021](https://hashnode.com/posts/urgent-2k-for-javascript-developers/61685e0353401f641ba16faa/comment/6168b2ce53401f641ba1755f)

This is really an interesting challenge, it did take some thinking. so here's my answer.

```
const studentsData = async function () {
  const allStudent = await fetch("all-student.txt").then((res) => res.text());
  const studentsSubmitted = await fetch("students-submitted.txt").then((res) =>
    res.text()
  );

  const allStudentArr = allStudent.split("\n");
  const studentsSubmittedArr = studentsSubmitted.split("\n");

  const studentsNotSubmitted = allStudentArr.filter(
    (students) => !studentsSubmittedArr.includes(students)
  );

  console.log(allStudentArr, "all students");
  console.log(studentsSubmittedArr, "students that submitted");
  console.log(studentsNotSubmitted, "students who didn't submit");

  console.log(
    `Students who turned in there assignments are ${studentsSubmittedArr.length}, while ${studentsNotSubmitted.length} students didn't submit`
  );
  console.log(
    `Total number of students are ${
      studentsSubmittedArr.length + studentsNotSubmitted.length
    }`
  );
};

studentsData();
```

**Here's how I went about it**

First I converted the google sheet files to text (txt) files so that they can be readable in a JavaScript file.

Both file names are:

```
all-student.txt
students-submitted.txt
```

Then I declared an asynchronous function called `studentsData`, which is responsible for handling all data fetching and doing all calculations.

Since both, all students data and does students that submitted are given I used the snippets shown below to get the text files as strings into my script file.

```
  const allStudent = await fetch("all-student.txt").then((res) => res.text());
  const studentsSubmitted = await fetch("students-submitted.txt").then((res) =>
    res.text()
  );
```

> Note the use of `res.text()`, this is because it's a text file the script is reading.

If you should log `allStudent` and `studentsSubmitted` variables to the console, the data shown will be similar to the below picture:

![Screenshot from 2021-10-14 23-10-20.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1634249502924/T3nPMKgXL.png)

The above image is in a string type which isn't needed, so I converted it to an array for both `allStudent` and `studentsSubmitted` variables making use of the `split("\n")` method.

> "\\n" denotes **new line** also read about the split method [here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split)

```
 const allStudentArr = allStudent.split("\n");
 const studentsSubmittedArr = studentsSubmitted.split("\n");
```

Now for the final step, I filter through the array of `allStudentArr` (all students email) checking if students that submitted their assignment are in the all students array.

If the above statement is true, then return the remaining students for the all students array.

By doing this I got all the answers for the task.

```
const studentsNotSubmitted = allStudentArr.filter(
    (students) => !studentsSubmittedArr.includes(students)
  );
```

![Screenshot from 2021-10-14 23-34-50.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1634250954830/7VCunaqM9.png)

**Behind the scene** I did Google some things, like

-   making use of the split method _(I knew there was a way to convert strings to an array, but I couldn't remember)_
-   writing an async function that reads text files (initially I just used the fetch method separately which wouldn't have worked)

That's it, I enjoyed working on the challenge.

[Ayodele Samuel Adebayo](https://hashnode.com/@unclebigbay)

[Oct 15, 2021](https://hashnode.com/posts/urgent-2k-for-javascript-developers/61685e0353401f641ba16faa/comment/6168b2ce53401f641ba1755f#reply-61690ff318374f257327a02e)

This looks nice 🙌,

Please can you submit your code solution on GitHub gist, along with the file to test with?

Then share the URL here.

Kudos for the well detailed guide

[Favourite Jome](https://hashnode.com/@Favourite)

[Oct 15, 2021](https://hashnode.com/posts/urgent-2k-for-javascript-developers/61685e0353401f641ba16faa/comment/6168b2ce53401f641ba1755f#reply-61692a7c18374f257327a284)

Here's the gist file [Ayodele Samuel Adebayo](https://hashnode.com/@unclebigbay)

[gist.github.com/jomefavourite/bae4b45f7b4ae245382…](https://gist.github.com/jomefavourite/bae4b45f7b4ae245382c1a631ccb150e)
