So, lets discuss why this happened.
For the first image the reason is not JS only this issue is because of Floating-point arithmetic. The fix is easy
console.log((0.1 + 0.2).toFixed(1));to get an idea about toFixed() click toFixed().
console.log(typeof(1+3+true+'medium'));it will return string.
Note: Once string is converted everything on right will be a string.
Thanks for reading.. suggestions are welcomed in the comments. 😄