Q:

check whether array contains every element of another array or not

I want to check if given array contains every single element of second array for example
['Laptop', 'PC', 'Ipad', 'Telephone', 'Smart Watch']
['Laptop,' 'PC', 'Smart Watch'] //true
['Laptop', 'Ipad', 'Banana'] //false

I tried this code:
var arr = [1, 2, 3];
var check = [3, 4, 5];

    var found = false;
      for (var i = 0; i < check.length; i++) {
          if (arr.indexOf(check[i]) > -1) {
             found = true;
             break;
          }
      }
    alert(found);  

It works but not as i want, it alerts true even if only one element from child is found in parent array.  so how can i implement what i want? 

A:

You could take a Set and check with Array#every. 

const check = (a, b) => b.every(Set.prototype.has, new Set(a));

var array1 = ['Laptop', 'PC', 'Ipad', 'Telephone', 'Smart Watch'],
    array2 = ['Laptop', 'PC', 'Smart Watch'],
    array3 = ['Laptop', 'Ipad', 'Banana'];

console.log(check(array1, array2)); //  true
console.log(check(array1, array3)); // false

ES5 (IE safe)

function check(a, b) {
    var items = a.reduce(function (o, v) {
            o[v] = true;
            return o;
        }, Object.create(null));
    return b.every(function (v) { return items[v]; });
}

var array1 = ['Laptop', 'PC', 'Ipad', 'Telephone', 'Smart Watch'],
    array2 = ['Laptop', 'PC', 'Smart Watch'],
    array3 = ['Laptop', 'Ipad', 'Banana'];

console.log(check(array1, array2)); //  true
console.log(check(array1, array3)); // false

