JSFiddle - React, Tailwind, and code Playground
by Diana Lemen
JavaScript
function pageCount(n, p) {
const isLessThanMid = p < n / 2;
console.log(isLessThanMid)
let count = 0;
if(isLessThanMid) {
console.log(count)
for(let i = 1; i <= p; i + 2) {
count = count + 1;
console.log(count)
}
} else {
/* for(let i = n; i === p; i - 2) {
count = count + 1;
} */
}
return count;
}
console.log(pageCount(6, 2))