isSubsetOf
//Make an array method that can return whether or not a context array is a // subset of an input array. To simplify the problem, you can assume that both // arrays will contain only strings. // var a = ['commit','push'] // a.isSubsetOf(['commit','rebase','push','blame']) // true // NOTE: You should disregard duplicates in the set. // var b = ['merge','reset','reset'] // b.isSubsetOf(['reset','merge','add','commit']) // true Array.prototype.isSubsetOf = function(array){ for(let i = 0; i < this.length; i++) { if(!array.includes(this[i])) { return false; } } return true };
댓글 영역