function array_between(a,b,c){
var backs=new Array();
for(var i=(a+1); i<b; i++){
backs.push(c[i]);
}
return backs;
}
console.log(array_between(3,10,arr));
function findBetweenValues(a,b,c){
var found=0;
var s=false; var e=false;
var backarrays=new Array();
for(var i=0; i<c.length; i++){
if(c[i]==a && found<1){s=i; found=1; }else if(c[i]==b && found==1){e=i; found=0; backarrays.push(array_between(s,e,c)); }
}
return backarrays;
}
console.log(findBetweenValues(5,6,arr));
function array_between(a,b,c){
var backs=new Array();
for(var i=(a+1); i<b; i++){
backs.push(c[i]);
}
return backs;
}
function findBetweenValues(a,b,c){
var found=0;
var s=false; var e=false;
var backarrays=new Array();
for(var i=0; i<c.length; i++){
if(c[i]==a && found<1){s=i; found=1; }else if(c[i]==b && found==1){e=i; found=0; backarrays.push(array_between(s,e,c)); }
}
return backarrays;
}
let arr = [2,4,3,5,4,2,3,4,2,5,6];
console.clear();
console.log('ARROUT');
console.log(array_between(3,10,arr));
console.log('ARROUTB');
console.log(findBetweenValues(5,6,arr));
<!DOCTYPE html>
<html>
<head>
<title>Extract an Array from an Array</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
<body>
<p id="demo"></p>
<script>
var myArray = [2,4,3,5,4,2,3, 4, 2, 5, 6,3,7,9];
myArray.splice(0, myArray.indexOf(5)+1);
myArray.splice(myArray.indexOf(6));
document.getElementById('demo').innerHTML = myArray;
</script>
</body>
</html>
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.