Skip to content

Instantly share code, notes, and snippets.

@naddison36
Last active June 13, 2017 13:06
Show Gist options
  • Save naddison36/8802db240399651ca99a277b70ec16fc to your computer and use it in GitHub Desktop.
Save naddison36/8802db240399651ca99a277b70ec16fc to your computer and use it in GitHub Desktop.
Percentages in node 8 console.log

The following code in node 6.10.3

console.log('percent: %d%, fraction: %d', 10, 0.1);

prints percent: 10%, fraction: 0.1

In node 8.1.0 it prints percent: 10 fraction: 0.1. Notice the % is no longer printed.

The following code gets back to the original node 6.10.3 output

console.log('percent: %d%%, fraction: %d', 10, 0.1);

Note the %% to print a single % in node 8

Also worth noting this problem doesn't happen if you are just printing one variable in node 8

console.log('percent: %d%', 10);

Prints percent: 10%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment