{"id":12144842,"date":"2019-11-18T09:05:27","date_gmt":"2019-11-18T09:05:27","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/counter-issue-with-javascript-engine\/"},"modified":"2019-11-18T09:05:27","modified_gmt":"2019-11-18T09:05:27","slug":"counter-issue-with-javascript-engine","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/counter-issue-with-javascript-engine\/","title":{"rendered":"Counter Issue with JavaScript engine"},"content":{"rendered":"<p>Hi,<\/p>\n<p>We found an issue in your Counter Up Block. Due to the way JavaScript handle small numbers, your Count Up Block is a little buggy with certain integers. For example: 228 \/ 100 * 100 give as a result : 227.9999999997 and get rounded to 227 by the &#8220;parseInt&#8221; method.<\/p>\n<p>Perhaps your should use a &#8220;Math.round&#8221; instead of the &#8220;parseInt&#8221;.<br \/>\nIf the use of parseInt is mandatory for you, simply invert the calculation ( &#8220;i * f \/ n&#8221; instead of &#8220;i \/ n * f&#8221; ) should limit the &#8220;buggy cases&#8221;.<\/p>\n<p>We saw it depends on a library you use (jQuery count up by Benjamin Intal). Maybe you should update this library in your package because it&#8217;s pretty old.<\/p>\n<p>Best regards<\/p>\n","protected":false},"template":"","class_list":["post-12144842","topic","type-topic","status-publish","hentry","topic-tag-count-up"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/12144842","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/12144842\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=12144842"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}