ds-algo-study
Version:
Just experimenting with publishing a package
19 lines (13 loc) • 352 B
JavaScript
/*
- Count number of full steps.
*/
function countSteps ( val, step, overflow ) {
val = Math.floor( val / step );
if ( overflow ) {
return val % overflow;
}
return val;
}
countSteps( 5, 2, 7 )
console.log('countSteps( 5, 2, 7 ): ', countSteps( 5, 2, 7 ));
console.log( 'countSteps(5,2,1): ', countSteps( 5, 2, 1 ) );