-1

Trying to get the following to pass my pipeline it is failing to pluralize. The rest of the change passed the pipeline just can't seem to get the pennies to pass. Help with this would be greatly appreciated. I have tried everything I could think of to get the pennies function to pass the pipeline.

function pluralizePennies(change) { 
    // calculate the number of pennies from the given change
    let pennies = Math.floor(change/0.01);
    // calculate the remaining change
    let changeRemainder = change % 0.01;
    // determine the correct string for the number of pennies, whether it is plural or not
    let penniesString;
    if (pennies == 1) {
        penniesString = 'penny';
    } else {
        penniesString = 'pennies';
    }
    // output the result to a given element
    document.getElementById('penny-output').textContent = `${pennies} ${penniesString}`;
    // return the remaining change
    return changeRemainder;
}


So, my output so far reads


$7.67
7 dollars
2 quarters
1 dime 
1 nickel
1 penny (but this needs to read 2 pennies 
Lynn
  • 1
  • 3

1 Answers1

0

don't use floats, use no change*100, etc. instead

Andrew
  • 1
  • 4
  • 19