Challenge: Adapter Pattern
Explore how to apply the Adapter Pattern to modify the turn logic in a JavaScript game without altering the interface players use. This lesson helps you understand adapting new functionality behind the scenes while preserving existing user calls, an essential skill in structural design patterns for coding interviews.
We'll cover the following...
We'll cover the following...
Problem statement
In this challenge, you are given a TruthAndDare program like this:
There is a variable turn that decides which player’s turn it is to give a dare or ask a question. The Getturn() function is used to set and return the turn. It is set to either 1 or 2. The playGame function is simple: it takes two players and depending on ...