|
|---|
| Ping Pong! |
| A game of table tennis almost always sounds like Ping! followed by Pong! |
| You know that Player 2 won if you hear Pong! as the last sound (since Player 1 didn’t return the ball back). |
| Given an array of Ping!, create a function that inserts Pong! in between each element. Also: |
- If win equals true, end the list with Pong! - If win equals false, end the list with Ping! |
| Examples |
<br>#Example 1<br>pingPong(["Ping!"], True)<br>output = ["Ping!", "Pong!"]<br><br>#Example 2<br>pingPong(["Ping!", "Ping!"], False)<br>output = ["Ping!", "Pong!", "Ping!"]<br><br>#Example 3<br>pingPong(["Ping!", "Ping!", "Ping!"], True)<br>output = ["Ping!", "Pong!", "Ping!", "Pong!", "Ping!", "Pong!"]<br> |
| Notes |
- Player 1 serves the ball and makes Ping!. - Return an array of strings. |