Skip to content

Instantly share code, notes, and snippets.

View nandobang's full-sized avatar

Luis Fernando Bang dos Santos nandobang

View GitHub Profile
@nandobang
nandobang / README.md
Created November 29, 2012 11:46
JavaScript in-string variables

JS in-string variables

We all love JS, don't we? Yes, we do. But, unfortunately, JS does not allow us to insert variables inside a string. We must close our quotes, concatenate with a + operator, and live our lives. What this tiny script does is replace anything inside #{ } for a variable. Ruby users know what this is.

Example

Let's say, you have two variables:

var mood = "nice";
@nandobang
nandobang / prime-tester.js
Created April 5, 2018 03:32
Simple script for benchmarking using Node and prime numbers.
const isPrime = (n) => {
let max = Math.floor(Math.sqrt(n));
for (var i = 2; i <= max; i++) {
if (n % i == 0) {
return false;
}
}
return true;