React devs VS the world

A team assembles to discuss the implementation a new feature … Dev #1: We will have this new component which fetches the webhooks from the database. Dev #2: Well, this data will have to be sorted and it should be done on the backend. React Dev: NO, YOU’RE WRONG! THAT IS NOT THE REACT WAY! […]

Read More React devs VS the world

JavaScript .sort() is broken

I am currently playing with Node.js and started to do some code challenges in JavaScript.In one of these challenges, an array is given and it asks for the smallest number, for example: arr = [85, -572, -1, 99] arr.sort() => [-1, -572, 85, 99] WHAT!? In ruby arr = [85, -572, -1, 99] arr.sort => […]

Read More JavaScript .sort() is broken

Format currency field with JavaScript

Last month I got a solution to format the currency fields from Wundertax’s declarations This is the function: var formatCurrency = function(element) { $this = $(element); var number = $this.val() number = number.replace(/[^0-9,.]/g, ”) if (number === ”) { number = ‘0,00’ } else { splitted_number = number.split(/[\,.]/g) if (splitted_number.length > 2) { decimal_numbers = […]

Read More Format currency field with JavaScript

var and let the difference in JavaScript

Javascrit has something called Hoisting. This is when all variables and functions are loaded before the program runs. function loadProfiles(userNames){ // some code… var loadingMessage = “Hold a sec… Profiles loading!”; // some code… } var loadingMessage = “Loading your profile!”; What will happen here is that the first declaration of loadingMessage will be loaded […]

Read More var and let the difference in JavaScript