Skip to content

Instantly share code, notes, and snippets.

@amilajack
Created June 12, 2016 23:57
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/eff71dd2f49848128a67bf9f2f164338 to your computer and use it in GitHub Desktop.
Save amilajack/eff71dd2f49848128a67bf9f2f164338 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.length < array2.length ? array1 : array2;
let other = array1.length > array2.length ? array1 : array2;
for (let i = 0; i < selected.length; i++) {
const item = selected[i]
if (other.includes(item)) {
merges.push(item)
console.log(item)
/*other = other.filter(function (e) {
return e !== i
})*/
}
}
return merges;
}
const nums1 = [1, 2, 2, 1];
const nums2 = [2, 2];
expect(superCheckerMergerDoer(nums1, nums2)).to.equal([2,2])
expect(superCheckerMergerDoer([1, 1], [1, 2])).to.equal([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.length < array2.length ? array1 : array2;
var other = array1.length > array2.length ? array1 : array2;
for (var i = 0; i < selected.length; i++) {
var item = selected[i];
if (other.includes(item)) {
merges.push(item);
console.log(item);
/*other = other.filter(function (e) {
return e !== i
})*/
}
}
return merges;
}
var nums1 = [1, 2, 2, 1];
var nums2 = [2, 2];
(0, _chai.expect)(superCheckerMergerDoer(nums1, nums2)).to.equal([2, 2]);
(0, _chai.expect)(superCheckerMergerDoer([1, 1], [1, 2])).to.equal([1]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment