// Store nearest similarity value
if (!closestSimilarityValue {
closestSimilarityValue = s
} else if (closestSimilarityValue > s) {
closestSimilarityValue = s
}
Proposed solution:
// Store nearest similarity value
if (!closestSimilarityValue && closestSimilarityValue !== 0) {
closestSimilarityValue = s
} else if (closestSimilarityValue > s) {
closestSimilarityValue = s
}
Bug in code:
Proposed solution: