Skip to content

Instantly share code, notes, and snippets.

@McLarenCollege
Last active March 11, 2022 05:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save McLarenCollege/57d10278dfc7477e7a1b3c1f1a63eee6 to your computer and use it in GitHub Desktop.
Save McLarenCollege/57d10278dfc7477e7a1b3c1f1a63eee6 to your computer and use it in GitHub Desktop.
mutual Friends

Alex's and Bob's friends are listed in two arrays.

let alexFriends = ['Samantha','Tom','John','Peter','Stacey'];
let bobFriends = ['Albert', 'Tom','Denver','Arnold','Stacey'];

Write a function named mutualFriends to print the names of the friends common to both Alex and Bob. If they dont have any common friends print "No Mutual Friends" You can assume that the names in each array will be unique.

For eg. for the given arrays the output should be

CODE TEMPLATE


let alexFriends = ['Samantha','Tom','John','Peter','Stacey'];
let bobFriends = ['Albert', 'Tom','Denver','Arnold','Stacey'];
mutualFriends(alexFriends,bobFriends);// "Tom" "Stacey"
alexFriends = ['Samantha','Tim','John','Peter'];
bobFriends = ['Albert', 'Tom','Denver','Arnold','Stacey'];
mutualFriends(alexFriends,bobFriends);// "No Mutual Friends"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment