Skip to content
Advertisement

PHP swapping elements between 2 tables

JavaScript

Question: Sort the 2 tables in such a way that table 1 contains only words that have at least 1 time the letter “u” and the second table the rest of the words that do not.

Hello, i’m a bit lost on displaying my code. I got the idea, which is adding elements that contains the letter ‘u’ to the 1st table, and deleting elements that doesn’t contain the letter, and vice versa for the 2nd table, but i’m not sure how to do it.

i considered swapping elements, not sure if that would work:

JavaScript

maybe this way:

JavaScript

Advertisement

Answer

Merge the two arrays together then sort everything into the groups you want.

JavaScript

Result:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement