Skip to content

Instantly share code, notes, and snippets.

View SavvasStephanides's full-sized avatar

Savvas Stephanides SavvasStephanides

View GitHub Profile
// This is your original array:
const animals = ['panda', 'turtle', 'giraffe'];
function convertToBaby(animalsArray){
// Start with an empty array. You will populate these in your loop:
const babyAnimals = [];
// Since it specifically asks for a loop:
for(var i = 0 ; i < animals.length ; i++){
// push() basically adds something at the end of an array:
babyAnimals.push(`baby ${animalsArray[i]`)
@SavvasStephanides
SavvasStephanides / Dockerfile
Created December 14, 2023 18:49
Accessibility audit Dockerfile
FROM buildkite/puppeteer:v1.15.0
RUN npm install --global --unsafe-perm pa11y-ci
RUN groupadd -r user && useradd -r -g user user
USER user
ENTRYPOINT ["pa11y-ci"]
@SavvasStephanides
SavvasStephanides / hello.js
Last active October 29, 2022 18:04
console-hello.js
console.log("Hello 👋");
.parent {
display: flex;
justify-content: center;
align-items: center;
}
const axios = require("axios")
const jsdom = require("jsdom")
const { JSDOM } = jsdom
async function run(){
const url = "https://savvas.me/explained/promises"
let response = await axios.get(url)
let html = response.data
$("#the-button")
.should(doSomething)
.when("clicked")
[
"ΑΚΑΝΘΟΥ",
"ΑΜΜΟΧΩΣΤΟΣ",
"ΛΕΥΚΟΝΟΙΚΟ",
"ΛΥΣΗ",
"ΚΑΡΑΒΑΣ",
"ΚΕΡΥΝΕΙΑ",
"ΛΑΠΗΘΟΣ",
"ΚΥΘΡΕΑ",
"ΛΕΥΚΑ",
@SavvasStephanides
SavvasStephanides / filterwithreduce.js
Created November 19, 2021 08:58
Implement 'filter' with reduce.
// Credit: Tweet from @oliverjumpertz: https://twitter.com/oliverjumpertz/status/1460184236917460993
// Filtering means: Test all elements of an array and take those with you that succeed the test
const filter = (array, callback) => array.reduce((accumulator, current, index, arr) => {
// This is the filter function. It decides which element is added to the new array
if (callback(current, index, arr)) {
// For each iteration, the current element is tested with the callback. If that test succeds
// it's added to the resulting array.
accumulator.push(current);
}
<div id="app">
<header>
<h1>Your cart</h1>
</header>
<main>
<div id="cart">
<i class="fas fa-shopping-cart" aria-hidden="true"></i> 2 items in cart
</div>
</main>
</div>
<div id="app">
<header>
<h1>Your cart</h1>
</header>
<main>
<div id="cart">
<i class="fas fa-shopping-cart"></i> 2 items in cart
</div>
</main>
</div>