Created
February 4, 2014 17:50
-
-
Save LESTADru/8808750 to your computer and use it in GitHub Desktop.
функция filterRangeInPlace(arr, a, b), которая получает массив с числами arr и удаляет из него все числа вне диапазона a..b.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>функция filterRangeInPlace(arr, a, b), | |
которая получает массив с числами arr и удаляет из него | |
все числа вне диапазона a..b.</title></head> | |
<body> | |
<script> | |
'use strict' | |
function filterRangeInPlace(arr, a, b){ | |
for(var i=0;i<arr.length;i++){ | |
if(a<=arr[i] && arr[i]<=b){ | |
arr.splice(i, 1); | |
i--; | |
} | |
} | |
} | |
var arr = [5, 3, 8, 1]; | |
alert(arr); | |
filterRangeInPlace(arr, 1, 4); | |
alert(arr); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment