Intermediate Algorithm Scripting - Sorted Union

Hello everyone, i wrote the code below waiting for the console to log an array containing all the values. Yet it logged 1 in the console.

(To avoid confusion, i know this is not the challenge’s code, i wrote this code as an exercise to practice things i’ve learnt and done in this exercise.)

function logMyFullName(Array) {
  let myFullName = []; 
  for (let B = 0; B < arguments.length; B = B + 1) {
let myFullNameAgain = arguments[B];
if (myFullName.indexOf(myFullNameAgain)) {
  return myFullName.push(myFullNameAgain);
  return myFullName;

console.log(logMyFullName(["Bushra", "Abdulsalam"],["Ghames"]));

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Safari/605.1.15

Challenge Information:

Intermediate Algorithm Scripting - Sorted Union

What were your expectations - what should be the result? What might explain that result is different?

be sure to check what each method you used returns

1 Like