JavaScript Array.some is not a function array some function example,array some function in java,typescript

I am attempting to pass 2 arrays to a function that filters through array 1 by array 2, then returns the filtered results.

I am not understanding why I am getting the error: "Uncaught TypeError: arr2.some is not a function"

Function Code:

function filterTF(arr1,arr2) 
{
    return arr1.filter(function(el) 
    {
        return arr2.some(function(e) 
        {
            return el.timeframe == e;
        });
    });
}

Array 1:

[
    {"time":"2016-11-30 02:45:00","signal":"Buy","symbol":"AUDNZDecn","price":"1.04605","timeframe":"M15","epoch":"1480473900","candel":"M151480481100"},{"time":"2016-11-30 02:41:00","signal":"Sell","symbol":"AUDJPYecn","price":"84.08700","timeframe":"M1","epoch":"1480473660","candel":"M11480480860"},{"time":"2016-11-30 02:24:59","signal":"Buy","symbol":"EURNZDecn","price":"1.48820","timeframe":"M5","epoch":"1480472699","candel":"M51480479900"}
]

Array 2:

5,15

Code that Runs the Function:

var timeframearr = localStorage.getItem("timeframe");

if(timeframearr.length === 0) 
{
    console.log("Wings - Timeframe Set: False");
    var timeframearr = [];
} 
else 
{
    var j = filterTF(j,timeframearr);
} 

Note: j is equal to a JSON parsed server response from an AJAX query that talks to a php script, which passes back a JSON response, aka the array above. timeframearr is either created new if its length is equal to 0, or if it exists in local storage then it gets it from there.

Code that puts timeframearr in local storage:

if ($('#timeframe-checkbox1').is(":checked")) 
{
    var t1 = $('#timeframe-checkbox1').val();
    console.log($('#timeframe-checkbox1').val());
    timeframearr.push(t1);
}

if ($('#timeframe-checkbox2').is(":checked")) 
{
    var t2 = $('#timeframe-checkbox2').val();
    console.log($('#timeframe-checkbox2').val());
    timeframearr.push(t2);
}

if ($('#timeframe-checkbox3').is(":checked")) 
{
    var t3 =  $('#timeframe-checkbox3').val();
    console.log($('#timeframe-checkbox3').val());
    timeframearr.push(t3);
}

localStorage.setItem("timeframe", timeframearr);

Goal: What I am trying to accomplish/understand is how to do is filter by multiple "timeframe" values of the array at a time, so that when a user clicks a checkbox for a combination of any of the three timeframes, I can pull the value from the checkboxes and filter the array by whatever combination of checkboxes the user had selected. ex. "M1", "M5", "M15", "M1,M5" or M1,M15" or M5,M15" or "M1,M5,M15" and so on.

The new array that is returned/filtered will get passed to a jquery each loop, that will then go through the data and append the data to a div. (I have this part working already)

Appreciate any guidance!

Answer:1

I have a 10 x 10 board and a button (in the demo given below I've minimized that to 3 x 3 ). When users click on the button the system generates a random number 1 to 9. document.getElementById(...

I have a 10 x 10 board and a button (in the demo given below I've minimized that to 3 x 3 ). When users click on the button the system generates a random number 1 to 9. document.getElementById(...

I am trying to add br tag between the text in react. can you guys tell me how to add it. I tried adding br tag... but if I add I get tag in the browser. providng my code below. can you guys tell me ...

I am trying to add br tag between the text in react. can you guys tell me how to add it. I tried adding br tag... but if I add I get tag in the browser. providng my code below. can you guys tell me ...

I wrote a simple code to choose random name from four, using "random_word();" function and it doesn't work. It says:"undefined". Can anyone explain me why and help to fix it? Thanks for all help. var ...

I wrote a simple code to choose random name from four, using "random_word();" function and it doesn't work. It says:"undefined". Can anyone explain me why and help to fix it? Thanks for all help. var ...

  1. javascript function returning undefined
  2. javascript function returning function
  3. javascript function returning multiple values
  4. javascript function returning value
  5. javascript function returning boolean
  6. javascript function returning object
  7. javascript function returning promise
  8. javascript function returning array
  9. javascript function returning nan
  10. javascript function returning true or false
  11. javascript function returning another function
  12. javascript function returning two values
  13. javascript function returning 2 values
  14. javascript function returning int
  15. javascript function returning json
  16. javascript function returning a boolean value
  17. javascript function returning json object
  18. javascript function returning html
  19. javascript function returning undefined value
  20. javascript function returning integer

I'm having some trouble with using Dropzone.js within a standard html form. With the code I have, everything is working as it should, I can click the area to add an image, I can only add one image at ...

I'm having some trouble with using Dropzone.js within a standard html form. With the code I have, everything is working as it should, I can click the area to add an image, I can only add one image at ...

  1. dropzone form submit
  2. dropzone submit form with files
  3. dropzone submit form without files
  4. dropzone submit form data
  5. dropzone js form submit
  6. dropzone processqueue on form submit
  7. dropzone upload on form submit
  8. dropzone upload file on form submit
  9. dropzone js upload on form submit