My question is how can i make a Probability function to show how a string that i add matches other strings based on vowels
input text(reading in from the same directory and it is in columns like so)
Lorem
ipsum
dolo
var fs = require('fs');
var array = fs.readFileSync('input.txt').toString().split("\n");
const asc = array.sort((a,b) => a.length - b.length);
parts = 4;
function splitToChunks(array, parts) {
let result = [];
for (let i = parts; i > 0; i--) {
result.push(array.splice(0, Math.ceil(array.length / i)));
}
function isVowel(x) {
return (/[aeiou]/i).test(x);
}
function countVowels(strChar, strchar2) {
var count1 = strChar.split('').filter(isVowel).length;
var count2 = strchar2.split('').filter(isVowel).length;
if (count1 === count2) return strChar.localeCompare(strchar2);
return count1 - count2
}
for (let i = 0; i < result.length; i++) {
console.log(result[i].sort(countVowels));
}
return result;
}
splitToChunks(asc, 4);