UNPKG

ielts-band-calculator

Version:

This package helps people to calculate overall balls of Ielts, in 4 sections

17 lines (16 loc) 581 B
const overallBand = (listening: number, reading: number, writing: number, speaking: number) => { // overall calculating let calc = (listening + reading + writing + speaking) / 4; // getting residual let residual = calc - Math.trunc(calc) //conditional checking if (residual === 0) { return calc; } else if (residual >= 0.25 && residual < 0.75) { return `${Math.floor(calc)}.5`; } else if (residual <= 0.25) { return Math.floor(calc); } else if (residual >= 0.75) { return Math.ceil(calc); } }