<HTML>
<body>
</body>
<script>
let arr = [1, 2, 3, 4, 5, 6, 7];
function inBetween(a, b) {
return function(x) {
return x >= a && x <= b;
};
}
alert( arr.filter(inBetween(3, 6)) ); // 3,4,5,6
function inArray(arr) {
return function(x) {
return arr.includes(x);
};
}
alert( arr.filter(inArray([1, 2, 10])) ); // 1,2
</script>
</HTML>
<!--
my solutions
function inBetween(a, b){
let label = -1;
return function(){
label++;
if(arr[label] >= a && arr[label] <= b ) return true;
};
}
//where the fuck x comes from and how the hell anyone
knows that is an iteral of array
//yeah now i know how to use filter() better thats thw whole point
//well yeah i could not think of the functino include
absolutely my bad yes
function inArray(inArr){
let count = 0;
return function(x){
if(x == inArr[count] && count <inArr.length)
{
count++;
return true;
}
};
}
-->
<body>
</body>
<script>
let arr = [1, 2, 3, 4, 5, 6, 7];
function inBetween(a, b) {
return function(x) {
return x >= a && x <= b;
};
}
alert( arr.filter(inBetween(3, 6)) ); // 3,4,5,6
function inArray(arr) {
return function(x) {
return arr.includes(x);
};
}
alert( arr.filter(inArray([1, 2, 10])) ); // 1,2
</script>
</HTML>
<!--
my solutions
function inBetween(a, b){
let label = -1;
return function(){
label++;
if(arr[label] >= a && arr[label] <= b ) return true;
};
}
//where the fuck x comes from and how the hell anyone
knows that is an iteral of array
//yeah now i know how to use filter() better thats thw whole point
//well yeah i could not think of the functino include
absolutely my bad yes
function inArray(inArr){
let count = 0;
return function(x){
if(x == inArr[count] && count <inArr.length)
{
count++;
return true;
}
};
}
-->
댓글
댓글 쓰기