
This function picks an email from an array of students who submitted assignments and checks for a match in the array containing all students' emails while traversing. Once found, it deletes the email from the array (all students email array). At the end of the loop, the emails of students who did not submit will remain and the function returns an array containing their emails, the number of students who submitted, and the number of students who didn't. πππ Not the best of solutions but it was fun giving it a try.
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:

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
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)
);

Behind the scene I did Google some things, like
That's it, I enjoyed working on the challenge.


The function receives both emails as string inputs. It checks emails in the general emails string that are not contained in the emails of those that submitted the assignment by utilizing the filter function. The emails are also converted to small letters in case there is a mix of cases.
It is expected that the file is downloaded in CSV (character-separated values) and the strings copied as inputs to the function.
Software Engineer @bug0
Summary
I enjoyed solving this problem. My process goes as follow:
`getData()- function in javascript are code that performs a particular task when called.didnt_submitand assigned it to an empty array - variable in javascript are like a container that holds different type of information, while array in javascript are ordered list or collection of datagetData()function then fetches the data of all students and students who submitted from the google sheet which i have converted to.txtformatsplit()method - thesplit()method in javascript takes a string/strings and return a new array of that string/stringsforEach()method in javascript -forEach()method loops through an array and executes a call back function once for each element in the array. Call back function are function that are passed into another function and are only executed after another function has finished executing. In this case, everytime the loop goes through the array of all the students, it checks if the email string returned from each loop is included in the array of students who submitted, if its not, it then pushes the string into the empty arraydidnt_submitthat was declared earlier on