Skip to content

Instantly share code, notes, and snippets.

@bartcis
bartcis / modified_style.css
Created May 12, 2019 14:41
First modification of styles
.old-input[type="text"],
.old-input[type="email"],
.old-input[type="number"] {
color: red;
}
.new-input {
color: blue;
}
@bartcis
bartcis / modified_style_2.css
Created May 12, 2019 14:43
Styles with !important rule
.old-input[type="text"],
.old-input[type="email"],
.old-input[type="number"] {
color: red;
}
.new-input {
color: blue !important;
}
@bartcis
bartcis / specificity_solution1.css
Created May 12, 2019 14:49
First solution for the problem
.new-input[type="text"] {
color: blue;
}
@bartcis
bartcis / specificity_solution2.css
Created May 12, 2019 14:51
Hack around !important
.new-input.new-input.new-input {
color: blue;
}
@bartcis
bartcis / algo_mid_one_1.js
Last active August 5, 2019 18:41
Difference between two arrays - solution 1
const arrayOne = [1, 4, 5, 7, 3, 8, 1, 9];
const arrayTwo = [3, 7, 1, 12, 9, 5, 24, 16];
function diffArrayBasic(array1, array2) {
// 1 - Create empty string to be returned
let newArray = [];
// 2 - Function that finds unique element in regards to the other array
function uniqueElement(first, second) {
// 3 - Loop through an array
@bartcis
bartcis / algo_mid_one_2.js
Last active August 5, 2019 18:41
Difference between two arrays - solution 2
const arrayOne = [1, 4, 5, 7, 3, 8, 1, 9];
const arrayTwo = [3, 7, 1, 12, 9, 5, 24, 16];
function diffArrayInt(array1, array2) {
// 1. Create new array
const newArr = [];
// 2. Combine the two array and sort
const orderedArr = [...array1, ...array2].sort();
// 3. Loop through the ordered Array
@bartcis
bartcis / algo_mid_one_3.js
Last active August 5, 2019 18:42
Difference between two arrays - solution 3
const arrayOne = [1, 4, 5, 7, 3, 8, 1, 9];
const arrayTwo = [3, 7, 1, 12, 9, 5, 24, 16];
function diffArrayInt(array1, array2) {
// 1. Return a new array that will follow this rules
return (
// 2. Combine two arrays
[...array1, ...array2]
// 3. Check each element if it's unique return in a new array
.filter((item) => !array1.includes(item) || !array2.includes(item))
@bartcis
bartcis / algo_mid_two_1.js
Created May 27, 2019 14:57
Sum up all odd Fibbonaci numbers - solution 1
// All odd Fibbonaci's
function sumOddFibsBasic(number) {
// 1. Create variables storing two latest values from the Fibbonaci numbers
// and value of a final sum off only odd numbers
let previousNum = 0;
let currentNum = 1;
let result = 0;
// 2. While loop iterates as long as current value is smaller that function parameter
while (currentNum <= number) {
@bartcis
bartcis / algo_mid_two_2.js
Created May 27, 2019 14:59
Sum up all odd Fibbonaci numbers - solution 2
// All odd Fibbonaci's
function sumOddFibsAdv(number) {
// 1. Create array with the two first values from the sequence
let fibs = [0, 1];
// 2. Create the number sequence till defined parameter
for (let fib = 1; fib <= number; ) {
fibs.push(fib);
fib = fibs[fibs.length - 1] + fibs[fibs.length - 2];
}
@bartcis
bartcis / algo_mid_three.js
Last active December 18, 2019 12:11
Convert Arabic numbers to Roman notation
// Conver Arabic to Roman Numbers
function romanConventerBasic(number) {
// 1. Create array with roman numbers and arabic equivalents
const decimalValue = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1];
const romanValue = ['M','CM','D','CD','C','XC','L','XL','X','IX','V','IV','I'];
// 2. New variable that will be romanized number
let romanized = '';