Test simple map function

Testing 'inline' map functions with callback

by Chris

HTML

<script src='https://cdn.jsdelivr.net/gh/naptha/[email protected]/dist/tesseract.min.js'></script>
<div id="banner-message">
  <p id="test">test</p>
  <button>Map</button>
</div>

JavaScript

var test_map = [1, 3, 5];
// find elements
var banner = $("#banner-message")
var button = $("button")

var msg = $("#test");

// handle click and add class
button.on("click", function() {
  msg.html(test_map.map(cube))
})

function addOne(number) {
  return number + 1;
}

function square(n) {
  return n * n;
}

function cube(n) {
  return n * n * n + "-";
}

function testMap(value, index, array) {
  console.log(value, index, array);
}

console.log(Tesseract);



function printIslandsWithNeighbor() {

   for (i in Islands) {

      var island = new Island();
      island.id = Islands[i].id;
      island.name = Islands[i].name;
      island.x = Islands[i].x;
      island.y = Islands[i].y;
      island.size = Islands[i].size;
      island.neighbors_dist = distanceToNeighbors(selected_islands);
         temp.push(island);
   }
   console.log(temp);
}

function distanceToNeighbors(array) {

   var neighbors_dist = [];

   for (i in array) {
      // Do not get distance on self
      if (i > 0) {
      // if (i != index) {
         var dist = pythagoreanTheorem(value.x, value.y, array[i].x, array[i].y);
         neighbors_dist.push(dist);
      } else {
         neighbors_dist.push(0);
      }
   }
   console.log(neighbors_dist);
   return neighbors_dist;
}