-2

This code outputs a number with many decimal places.. I'd like it limited to just one... this code gets me my desired result BUT with too many characters displayed.

I'm a total noob....

function oninputchange() {
$output.textContent = $input.value.split(/\s/g).map(syllable).reduce(sum)/4.7;
}

The results are expected... Just want fewer decimal places

Bob
  • 1
  • 1
  • I've seen these examples but I don't see how to implement in my specific case, can someone show me? I don't much care about accurate numbers.. Just care about how it looks in the display :) The simplest solution is best for me. – Bob Jan 13 '19 at 22:40

1 Answers1

0

Use method toFixed() for limit the decimal number to show

  • Tried that but didn't work... please show me how to implement in code? – Bob Jan 14 '19 at 00:21
  • This is how you can implement it: $output.textContent = $input.value.split(/\s/g).map(syllable).reduce(sum)/4.7.toFixed(0); toFixed() gets as paramater how many decimal you wanna show. – iamousseni Jan 17 '19 at 07:46