Skip to content

Instantly share code, notes, and snippets.

View fionnachan's full-sized avatar
🐱
Je code, donc je suis. ʕ•ᴥ•ʔ

Fionna Chan fionnachan

🐱
Je code, donc je suis. ʕ•ᴥ•ʔ
View GitHub Profile
@fionnachan
fionnachan / tictactoe_before_refactor.js
Created February 24, 2019 10:01
Tic Tac Toe before refactoring
var boxes = document.querySelectorAll('.box');
var gamestatus = { 1: '', 2: '', 3: '', 4: '', 5: '', 6: '', 7: '', 8: '', 9: '' };
var seq = [];
var seq_x = [];
var seq_o = [];
var gameEnd = false;
var $ = el => document.querySelector(el);
function changed(el) {
@fionnachan
fionnachan / semver_attempt_3.js
Last active October 11, 2018 14:44
Check Semantic Versioning 3rd attempt
const correctSemverRange = (ver, range) => {
const foundSymbol = range.match(/\D/);
const rangeSymbol = foundSymbol ? foundSymbol[0] : 'default';
const rangeNumArr = range.match(/[^\^|\~]+/)[0].split('.');
const verNumArr = ver.split('.');
const shouldMatch = {
'^': [['=', '>', ''], ['=', '=', '>=']],
'~': [['=', '=', '>=']],
'default': [['=', '=', '=']]
};
@fionnachan
fionnachan / semver_attempt_2.js
Created October 10, 2018 13:58
Check Semantic Versioning 2nd attempt
const correctSemverRange = (ver, range) => {
const shouldMatch = {
'^': [['=', '>', ''], ['=', '=', '>=']],
'~': [['=', '=', '>=']],
'default': [['=', '=', '=']]
};
const rangeSymbol = (isNaN(parseInt(range.substring(0, 1)))) ? range.substring(0, 1) : 'default';
const verNumArr = ver.split('.');
let rangeNumArr = range.split('.');
let result = false;
@fionnachan
fionnachan / semver_attempt_1.js
Last active October 10, 2018 13:59
Check Semantic Versioning 1st attempt
const correctSemverRange = (ver, range) => {
const shouldMatch = {
'^': [['=', '>', ''], ['=', '=', '>=']],
'~': [['=', '=', '>=']],
'default': [['=', '=', '=']]
};
const rangeSymbol = range.substring(0, 1);
const verNumArr = ver.split('.');
let rangeNumArr = range.split('.');
let result = false;