Skip to content

Instantly share code, notes, and snippets.

View Magistern's full-sized avatar

Johan Kohlin Magistern

  • Jönköping University
View GitHub Profile
@Magistern
Magistern / String2number-concatenation.js
Created February 9, 2019 09:54
Strin2number-concatenation
"a " + "ha" // "a ha"
"F" + "1" // "F1"
"F" + 1 // "F1" automatic type conversion
"2" + "1" // "21"
"2" + 1 // "21" automatic type conversion
@Magistern
Magistern / nextColor.js
Created February 5, 2019 21:54
nextColor() returns a css color string: "background-color:rgb(192,245,249)"
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
This script contains ES6 specific generator functions. Use es6-shim.js
The following code is an adaptation of the original code created
by @jbum | https://krazydad.com/tutorials/makecolors.php
It is ok to include this script in your labs to
generate new colors for iterative purposes.
> nextColor() returns a css color string
* * * * * * * * * * * * * * * * * * */
function nextColor() {
@Magistern
Magistern / JS_random.js
Last active January 17, 2019 14:16
The missing random number generator for JavaScript with a random number tester function that displays the spread of random numbers on a given iteration count.
function random(min, max) {
/* defaults to: 1-10 */
min = isNaN(+min) ? 1 : +min
max = isNaN(+max) ? 10 : +max
return Math.floor(Math.random() * (max-min+1)+min)
}
/*
examples:
random(1,80) -> 1-80
random() -> 1-10 (using the defaults)
@Magistern
Magistern / a-simple-vue-app.markdown
Last active April 10, 2018 22:58
A simple vue app