function isarray(arr) {
return Array.isArray(arr);
}
console.log(isarray("w3resource"));
console.log(isarray([1, 2, 4, 0]));
/-----------------------------------------------------------------/;
function array_Clone(array) {
let arr1 = [];
for (let item of array) {
arr1.push(item);
}
return arr1;
}
console.log(array_Clone([1, 2, 4, 0]));
console.log(array_Clone([1, 2, [4, 0]]));
/-----------------------------------------------------------------/;
function first(params, n) {
var temp=params.slice(0,n);
return temp;
}
console.log(first([7, 9, 0, -2]));
console.log(first([], 3));
console.log(first([7, 9, 0, -2], 3));
console.log(first([7, 9, 0, -2], 6));
console.log(first([7, 9, 0, -2], -3));
/-----------------------------------------------------------------/;
function joiner(params) {
var first = params.join(",");
var second = params.join("+");
return { first, second };
}
console.log(joiner(["Red", "Green", "White", "Black"]));
/-----------------------------------------------------------------/;
var arr1 = [3, "a", "a", "a", 2, 3, "a", 3, "a", 2, 4, 9, 3];
var mf = 1;
var m = 0;
var item;
for (var i = 0; i < arr1.length; i++) {
for (var j = i; j < arr1.length; j++) {
if (arr1[i] == arr1[j]) m++;
if (mf < m) {
mf = m;
item = arr1[i];
}
}
m = 0;
}
console.log(item + " ( " + mf + " times ) ");
/-----------------------------------------------------------------/;