more efficient version of this?
- by john connor
i have this thingy here :
function numOfPackets(bufferSize, packetSize) {
if (bufferSize <= 0 || packetSize > bufferSize) return 0;
if (packetSize < 0) throw Error();
var out = 0;
for(;;){
out++;
bufferSize = bufferSize - packetSize;
if( packetSize > bufferSize ) break;
}
return out;
}
which i run at often , can u give me more efficent variant of it?