Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

quiz javascript

YOUR MISSION
Google maps recently discovered a mysterious place last week...
They need you to calculate new data on this unknown archipel...
Do you feel ready to continue this adventure?
 
INSTRUCTIONS :
Return the truncated percentage of islands on the map.

EXEMPLES
[
  [0,0,0,0,0],
  [1,1,0,0,0],
  [1,1,0,0,0],
  [0,0,0,1,1],
]
=>30%
const map=[
  [0,0,0,0,0],
  [1,1,0,0,0],
  [1,1,0,0,0],
  [0,0,0,1,1],
];
function count Islands(map){
  return map.reduce((count Island,row)=>{
    return count Island+row.filter(Boolean).length
  },0);
}
 
PREVIOUS NEXT
Tagged: #quiz #javascript
ADD COMMENT
Topic
Name
2+2 =