Skip to content

Instantly share code, notes, and snippets.

View samcyn's full-sized avatar
🎯
Focusing

Samson Iyanda samcyn

🎯
Focusing
View GitHub Profile
@samcyn
samcyn / sorting.js
Created February 26, 2017 12:08
Sorting arrays of Objects
const footballers = [
{
name: "Rooney",
age: 30
},
{
name: "Ronaldo",
age: 32
},
{
@samcyn
samcyn / mat.html
Last active November 1, 2017 00:29
A simple mat. 30Days CSS challenge.. DAY1 challenge
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style type="text/css">
body{
background: #EEE;
height: 100vh;
@samcyn
samcyn / cuboid.html
Last active November 2, 2017 14:57
A match box loader. Day2 30 days challenge
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
.stage {
position: absolute;
@samcyn
samcyn / eye.html
Created November 3, 2017 13:50
Eye animation. 3rd day 30 days challenge.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
body{
height: 100vh;
var button = document.querySelector('button');
Rx.Observable.fromEvent(button, 'click')
.throttleTime(1000)
.map( (data) => { return data.clientY })
.subscribe(
(coordinate) => console.log(coordinate)
);
@samcyn
samcyn / flatten.js
Created December 19, 2018 14:40
Flattening arrays
var givenArray = [1,2,[3,4,5], 6, [7,8]];
function flattenController(arr) {
return arr.reduce(function (flat, toFlatten) {
return flat.concat(Array.isArray(toFlatten) ? flatten(toFlatten) : toFlatten);
}, []);
}
flattenController(givenArray); // [1, 2, 3, 4, 5, 6, 7, 8];
@samcyn
samcyn / solution.js
Last active November 5, 2019 19:25
FLAT A LIST(ARRAY) USING JAVASCRIPT
/*
A - S I M P L E - F L A T - L I S T - H A N D L E R
- U S I N G - F L A T
*/
const flatListHandler = (nestedArray, depth) => {
return nestedArray.flat(depth);
}
// U S A G E -
const nestedArray = [1, 2, 3 ,4 , [5, 6, 7], 8];