Professional Development

Refactoring a While Loop with Recursion in JavaScript

A quick example of how to refactor out a While loop in JavaScript by using recursion instead. The problem is as follows (from TestDome): Your company assigns each customer a membership ID, and you are implementing a check digit for those IDs. The check digit should be calculated by adding up all digits in each… Continue reading Refactoring a While Loop with Recursion in JavaScript

Professional Development

Class properties versus Constructor in React

A simple counter component in React can look like this: The component initializes the state variable “counter” with the value zero and then updates it by one every time the button is clicked. See it working here. This same code can be written much more cleanly using class properties instead of constructor properties, like so:… Continue reading Class properties versus Constructor in React

Knowledge · Professional Development

Clean Aggregation with JavaScript ‘Reduce’

A common beginner (?) programming question is as follows: Given an array of items, find how many instances of each item occurs in the array. For example, given the below array of US states, return an object with the count of number of instances of each state: The interesting thing about this problem is it… Continue reading Clean Aggregation with JavaScript ‘Reduce’

Entrepreneurship

Regulatory Considerations for Consumer Electronics Products

Designing a new consumer electronic product from scratch has led me to the broad and intimidating subject of regulatory requirements. If you want to import original products from China, or Vietnam, or India, or anywhere else, to the US, Europe, Australia, or other western markets, you are required by law to comply with numerous regulations… Continue reading Regulatory Considerations for Consumer Electronics Products