From 17ba5da6d592fd08ee357bcfe9f408c326cb6e82 Mon Sep 17 00:00:00 2001 From: Julian Simioni Date: Thu, 23 Jul 2015 15:43:01 -0400 Subject: [PATCH] Replace array iteration boilerplate with .map Keeps the focus of the code on the actions to be performed, rather than the grunt work of iterating through the array. --- sanitiser/_geo.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/sanitiser/_geo.js b/sanitiser/_geo.js index 5bd2bb7c..28b92812 100644 --- a/sanitiser/_geo.js +++ b/sanitiser/_geo.js @@ -50,14 +50,10 @@ function sanitize_bbox( clean, param ) { var bboxArr = param.split( ',' ); if( Array.isArray( bboxArr ) && bboxArr.length === 4 ) { + var bbox = bboxArr.map(parseFloat); - var bbox = []; - for( var ind = 0; ind < bboxArr.length; ind++ ){ - var num = parseFloat( bboxArr[ ind ] ); - if( isNaN( num ) ){ - return; - } - bbox.push( num ); + if (bbox.some(isNaN)) { + return; } clean.bbox = {