Skip to content

Instantly share code, notes, and snippets.

@amilajack
Created June 13, 2016 18:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amilajack/f8626dcea6bf739e4a4851dd494736b7 to your computer and use it in GitHub Desktop.
Save amilajack/f8626dcea6bf739e4a4851dd494736b7 to your computer and use it in GitHub Desktop.
esnextbin sketch
<!DOCTYPE html>
<html>
<body>
<p>Image to use:</p>
<img id="scream" width="220" height="277" src="http://www.w3schools.com/tags/img_the_scream.jpg" alt="The Scream">
<p>Canvas:</p>
<canvas id="myCanvas" width="240" height="297" style="border:1px solid #d3d3d3;">
Your browser does not support the HTML5 canvas tag.
</canvas>
<script>
window.onload = function() {
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
var img = document.getElementById("scream");
ctx.drawImage(img, 10, 10);
}
</script>
<p><strong>Note:</strong> The canvas tag is not supported in Internet
Explorer 8 and earlier versions.</p>
</body>
</html>
import { expect } from 'chai'
function superCheckerMergerDoer(array1, array2) {
const merges = []
let selected = array1
let other = array2
for (let i = 0; i < selected.length; i++) {
const item = selected[i]
if (other.includes(item)) {
console.log(other)
console.log(selected)
merges.push(item)
other.splice(i, 1)
selected.splice(i, 1)
console.log('..........')
console.log(other)
console.log(selected)
}
}
return merges
}
const nums1 = [1, 2, 2, 1]
const nums2 = [2, 2]
expect(superCheckerMergerDoer(nums1, nums2)).to.eql([2,2])
expect(superCheckerMergerDoer([1, 1], [1, 2])).to.eql([1])
{
"name": "esnextbin-sketch",
"version": "0.0.0",
"dependencies": {
"chai": "3.5.0"
}
}
'use strict';
var _chai = require('chai');
function superCheckerMergerDoer(array1, array2) {
var merges = [];
var selected = array1;
var other = array2;
for (var i = 0; i < selected.length; i++) {
var item = selected[i];
if (other.includes(item)) {
console.log(other);
console.log(selected);
merges.push(item);
other.splice(i, 1);
selected.splice(i, 1);
console.log('..........');
console.log(other);
console.log(selected);
}
}
return merges;
}
var nums1 = [1, 2, 2, 1];
var nums2 = [2, 2];
(0, _chai.expect)(superCheckerMergerDoer(nums1, nums2)).to.eql([2, 2]);
(0, _chai.expect)(superCheckerMergerDoer([1, 1], [1, 2])).to.eql([1]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment