-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproblem-two.js
More file actions
12 lines (10 loc) · 1.29 KB
/
problem-two.js
File metadata and controls
12 lines (10 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
// Oh no, it doesn't look like the fence post is holding! It seems that there are just too many zombies, and they are threatening to overwhelm your defenses. Luckily for you, the writer of these JavaScript problems doesn't want you to die, so you also miraculously have a fleet of robot turrets at your command to help repel the attack.
// Write a function called directTurretDefenceCommand that takes in 2 parameters: The first should be called numOfTurrets (which will always be given a positive integer argument value), and the second should be called numOfDetectedZombies (which will always be given a positive integer argument value).
// Your function should log to the console a string that matches the following format: "Directing X turrets' fire to zombie # ____." where the X represents how many turrets you have, and the blank space represents the current zombie being targeted. Your function should run as many loop iterates as there are numOfDetectedZombies.
// Write your code below:
function directTurretDefenceCommand(numOfTurrets, numOfDetectedZombies){
for (let numOfCurrentZombies = 0; numOfCurrentZombies <= numOfDetectedZombies; numOfCurrentZombies++){
console.log("Directing " + numOfTurrets + " turrets' fire to zomie # " + numOfCurrentZombies + ".");
}
}
directTurretDefenceCommand(10,17)