Deal with empty strings being inserted into the key

This commit is contained in:
Amelia 2022-06-05 18:35:23 +01:00
parent 4391df8c1a
commit f27aab1d3d
1 changed files with 16 additions and 0 deletions

View File

@ -42,6 +42,22 @@ function getKey(element: cheerio.Cheerio<cheerio.Element>) {
const numbers = splitKey[0].split(" ");
const stars = splitKey[1].split(" ");
// Not sure why, but an empty string is being inserted into the array
numbers.forEach((value, i) => {
console.log(value == "");
if (value == "") {
numbers.splice(i, i);
}
});
stars.forEach((value, i) => {
if (value == "") {
numbers.splice(i, i);
}
});
console.log(stars);
return { numbers: numbers, stars: stars };
}