Skip to content

Instantly share code, notes, and snippets.

View transparenceweb's full-sized avatar

Phil Wright transparenceweb

View GitHub Profile
@transparenceweb
transparenceweb / all_unique.js
Last active May 31, 2022 17:18
Cassidoo code question #250
function allUnique(string) {
if (string.length !== (new Set(string)).size) {
console.log(`Duplicate characters, same case, in '${string}'`);
return false;
} else {
if (string.length !== (new Set(string.toLowerCase()).size)) {
console.log(`Duplicate characters across cases in '${string}'`);
return false;
} else {
console.log(`No duplication in '${string}'`);
@transparenceweb
transparenceweb / maximisedArray.js
Last active May 17, 2022 19:25
Solution for code challenge in issue #248 of rendezvous with cassidoo
const arr1 = [7, 4, 10, 0, 1];
const arr2 = [9, 7, 2, 3, 6];
const sortArr = (a, b) => {return b - a;};
const maximisedArray = function (arr1, arr2) {
const n = arr1.length;
const combinedArr = arr1.concat(arr2);
const sortedArr = combinedArr.sort(sortArr);
const uniqueElements = [...new Set(sortedArr)];
return uniqueElements.slice(0, n);
};
@transparenceweb
transparenceweb / cassidoo_code_question_meal_payment.js
Last active May 16, 2022 06:45
Code challenge from 9th May 2022 email from Cassidoo
let receipts = [
{ name: "Ximena", paid: 45 },
{ name: "Clara", paid: 130 },
{ name: "Ximena", paid: 100 },
{ name: "Cassidy", paid: 140 },
{ name: "Cassidy", paid: 76 },
{ name: "Clara", paid: 29 },
{ name: "Ximena", paid: 20 }
];
function whoOwes(array) {
@transparenceweb
transparenceweb / gtm-iframe-child.html
Last active November 13, 2018 02:29
Using Google Tag Manager to track a site and have a 3rd party element loading into an iframe. Need to track an event onclick within the iframe and have it push to the dataLayer on the parent page. Adding GTM snippet to child page not a possibility so using typical dataLayer.push({'event': 'event_name'}); will not work. Apply following workaround…
<!doctype html>
<html>
<head>
<title>Child page</title>
<!-- Stylesheet -->
<style type="text/css">
body
{