Home » Javascript » Comparing of dynamically created slice string with the other slice string upto limit?

Comparing of dynamically created slice string with the other slice string upto limit?

Posted by: admin August 19, 2018 Leave a comment

Questions:

Here I have two slices :-

 slice1=["Friday, 06-01-2018 8:00AM 11:00AM",
         "Saturday, 06-02-2018 8:00AM 11:00AM",
         "Sunday, 06-03-2018 8:00AM 11:00AM", 
         "Monday, 06-04-2018 8:00AM 11:00AM"]

 slice2 =["Monday, 06-04-2018 8:00AM 10:00AM",
          "Monday, 06-11-2018 8:00AM 10:00AM"]

Code I’m trying:-

  for (var i = 0; i < slice1.length; i++) {
    for (var j = 0; j < slice2.length; j++) {
        if (slice1[i]== slice2[j]) {
            console.log(slice2[j]);
        }
     }
   }

How will I compare each slice1 element with the each element of the slice2 range of the every string will be at 8:00AM the time will be change with other records because the slice a dynamically created. Is that possible to compare the slice element like that. For example "Monday, 06-04-2018 8:00AM" == "Monday, 06-04-2018 8:00AM". Can anybody will help me for this. I’m using jQuery for this. Thank you.

Answers: