diff --git a/javascript/1486-XOR-operation-in-an-array.js b/javascript/1486-XOR-operation-in-an-array.js new file mode 100644 index 000000000..ea3342f3b --- /dev/null +++ b/javascript/1486-XOR-operation-in-an-array.js @@ -0,0 +1,14 @@ +/** + * @param {number} n + * @param {number} start + * @return {number} + */ +var xorOperation = function(n, start) { + let nums = new Array(n).fill(0); // initialize a nums which is the length of n elements with 0 value of Array using Array() nad fill() + + for(let i=0; i a^b); // return the bitwise XOR of all elements of nums using reduce() +};