# Don't Touch Them (JavaScript)

**URL:** <https://discourse.codecombat.com/t/dont-touch-them-javascript/25970>\
**Category:** Level Help\
**Created:** [December 9, 2020, 9:17pm UTC](https://discourse.codecombat.com/t/dont-touch-them-javascript/25970 "2020-12-09T21:17:11Z")\
**Posts on this page:** 18\
**Page:** 2

<div class="post-metadata">

**Author:** ![jdad](https://avatars.discourse-cdn.com/v4/letter/j/898d66/32.png) [@jdad](https://discourse.codecombat.com/u/jdad)\
**Post date:** [December 10, 2020, 11:47pm UTC](https://discourse.codecombat.com/t/dont-touch-them-javascript/25970/25 "2020-12-10T23:47:50Z")

</div>

> [@abc](#):
>
> ace true with Tr

If it’s capitalized the code reads an error?

---

<div class="post-metadata">

**Author:** ![abc](https://avatars.discourse-cdn.com/v4/letter/a/2bfe46/32.png) [@abc](https://discourse.codecombat.com/u/abc)\
**Post date:** [December 10, 2020, 11:57pm UTC](https://discourse.codecombat.com/t/dont-touch-them-javascript/25970/26 "2020-12-10T23:57:49Z")

</div>

Replace all the `true` with `True`, and replace all the `false` with `False`.

---

<div class="post-metadata">

**Author:** ![abc](https://avatars.discourse-cdn.com/v4/letter/a/2bfe46/32.png) [@abc](https://discourse.codecombat.com/u/abc)\
**Post date:** [December 11, 2020, 12:00am UTC](https://discourse.codecombat.com/t/dont-touch-them-javascript/25970/27 "2020-12-11T00:00:25Z")

</div>

> [@jdad](#):
>
> `game.setGoalState(spawnMunchkinsGoal, True);`

Also if capitalizing it gives you an error, then why do you have this?

---

<div class="post-metadata">

**Author:** ![jdad](https://avatars.discourse-cdn.com/v4/letter/j/898d66/32.png) [@jdad](https://discourse.codecombat.com/u/jdad)\
**Post date:** [December 11, 2020, 12:05am UTC](https://discourse.codecombat.com/t/dont-touch-them-javascript/25970/28 "2020-12-11T00:05:28Z")

</div>

This is what it shows me if I change them all to capital. If I change the one in the while true loop it gives me an error immediately and won’t let me play the game.

 ![image](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/3X/4/c/4cc7ff865b1ed3f08ae064d4dde6d3607aece160.jpeg)

---

<div class="post-metadata">

**Author:** ![abc](https://avatars.discourse-cdn.com/v4/letter/a/2bfe46/32.png) [@abc](https://discourse.codecombat.com/u/abc)\
**Post date:** [December 11, 2020, 12:11am UTC](https://discourse.codecombat.com/t/dont-touch-them-javascript/25970/29 "2020-12-11T00:11:22Z")

</div>

Then change all of them to lowercase.

---

<div class="post-metadata">

**Author:** ![jdad](https://avatars.discourse-cdn.com/v4/letter/j/898d66/32.png) [@jdad](https://discourse.codecombat.com/u/jdad)\
**Post date:** [December 11, 2020, 12:13am UTC](https://discourse.codecombat.com/t/dont-touch-them-javascript/25970/30 "2020-12-11T00:13:33Z")

</div>

I’ve done that multiple times and I just did again. Still no success:

 ![image](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/3X/e/b/eb65522a419a743e5ce62f24e492008ae4345eaf.jpeg)

---

<div class="post-metadata">

**Author:** ![WaWa\_Yang](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/wawa_yang/32/17800_2.png) [@WaWa\_Yang](https://discourse.codecombat.com/u/WaWa_Yang)\
**Post date:** [December 11, 2020, 12:53am UTC](https://discourse.codecombat.com/t/dont-touch-them-javascript/25970/31 "2020-12-11T00:53:03Z")

</div>

@jdad i have been trough all the topic…If im not mistaken then the problem here is that you defeat more then 7 scouts but your game goal is not complete.

---

<div class="post-metadata">

**Author:** ![ineedhelpwithcoding](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ineedhelpwithcoding/32/30168_2.png) [@ineedhelpwithcoding](https://discourse.codecombat.com/u/ineedhelpwithcoding)\
**Post date:** [December 11, 2020, 4:54am UTC](https://discourse.codecombat.com/t/dont-touch-them-javascript/25970/32 "2020-12-11T04:54:25Z")

</div>

> [@jdad](#):
>
> took away the indentations.

you don’t take away the

```python
` ` `

```

---

<div class="post-metadata">

**Author:** ![Sydney\_Barger](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/sydney_barger/32/18106_2.png) [@Sydney\_Barger](https://discourse.codecombat.com/u/Sydney_Barger)\
**Post date:** [January 3, 2021, 8:22pm UTC](https://discourse.codecombat.com/t/dont-touch-them-javascript/25970/33 "2021-01-03T20:22:29Z")

</div>

these things are happening to me too

---

<div class="post-metadata">

**Author:** ![WaWa\_Yang](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/wawa_yang/32/17800_2.png) [@WaWa\_Yang](https://discourse.codecombat.com/u/WaWa_Yang)\
**Post date:** [January 3, 2021, 9:20pm UTC](https://discourse.codecombat.com/t/dont-touch-them-javascript/25970/34 "2021-01-03T21:20:40Z")

</div>

Hello and welcome to codecombat discourse! This is a cozy forum where you can share ideas, share fan art, get assistance for code, etc! Before you proceed, we hope that you review [this topic](https://discourse.codecombat.com/t/welcome-to-codecombat-discourse-forums/15601), which shows all essentials of this board! Thanks!

---

<div class="post-metadata">

**Author:** ![WaWa\_Yang](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/wawa_yang/32/17800_2.png) [@WaWa\_Yang](https://discourse.codecombat.com/u/WaWa_Yang)\
**Post date:** [January 3, 2021, 9:25pm UTC](https://discourse.codecombat.com/t/dont-touch-them-javascript/25970/35 "2021-01-03T21:25:35Z")

</div>

in the `while (true) }` loops its cap i think but in `game.setGoalState(dontTouchGoal)` its lower case

---

<div class="post-metadata">

**Author:** ![Eric\_Tang](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/eric_tang/32/15310_2.png) [@Eric\_Tang](https://discourse.codecombat.com/u/Eric_Tang)\
**Post date:** [January 3, 2021, 9:27pm UTC](https://discourse.codecombat.com/t/dont-touch-them-javascript/25970/36 "2021-01-03T21:27:53Z")

</div>

not for javascript, the “true” is lower case

---

<div class="post-metadata">

**Author:** ![WaWa\_Yang](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/wawa_yang/32/17800_2.png) [@WaWa\_Yang](https://discourse.codecombat.com/u/WaWa_Yang)\
**Post date:** [January 3, 2021, 9:28pm UTC](https://discourse.codecombat.com/t/dont-touch-them-javascript/25970/37 "2021-01-03T21:28:19Z")

</div>

ok cause i normally do python, i know a little javascript

---

<div class="post-metadata">

**Author:** ![Sydney\_Barger](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/sydney_barger/32/18106_2.png) [@Sydney\_Barger](https://discourse.codecombat.com/u/Sydney_Barger)\
**Post date:** [January 4, 2021, 1:23am UTC](https://discourse.codecombat.com/t/dont-touch-them-javascript/25970/38 "2021-01-04T01:23:55Z")

</div>

function createGenerator(spawnType, x, y, spawnAI) {  
var generator = game.spawnXY(“generator”, x, y);  
generator.spawnType = spawnType;  
generator.spawnAI = spawnAI;  
}

// Scouts are aggressive and munchkins are just walking.  
createGenerator(“scout”, 12, 12, “AttacksNearest”);  
createGenerator(“scout”, 68, 56, “AttacksNearest”);  
createGenerator(“munchkin”, 12, 56, “Scampers”);  
createGenerator(“munchkin”, 68, 12, “Scampers”);

var player = game.spawnPlayerXY(“duelist”, 40, 34);  
player.maxHealth = 1000;  
player.attackDamage = 20;  
player.maxSpeed = 20;

// These are our goals. Notice we save them in variables!  
var spawnMunchkinsGoal = game.addManualGoal(“Let 6 munchkins spawn.”);  
var dontTouchGoal = game.addManualGoal(“Don’t attack munchkins.”);  
var defeatScoutsGoal = game.addManualGoal(“Defeat 6 scouts.”);  
// game properties used to count new and defeated ogres.  
game.spawnedMunchkins = 0;  
game.defeatedScouts = 0;  
game.successGoal = 0;  
ui.track(game, “spawnedMunchkins”);  
ui.track(game, “defeatedScouts”);

function onSpawn(event) {  
game.spawnedMunchkins += 1;  
}

function onDefeat(event) {  
var unit = event.target;  
if (unit.type == “scout”) {  
game.defeatedScouts += 1;  
}  
if (unit.type == “munchkin”) {  
// dontTouchGoal is failed if a munchkin is defeated.  
game.setGoalState(dontTouchGoal, false);  
player.say(“Oops.”);  
}  
}

function checkGoals() {  
// If game.defeatedScouts is greater than 5:  
if (game.defeatedScouts \> 5) {  
// Set defeatScoutsGoal state as successful…  
game.setGoalState(defeatScoutsGoal, true);  
}  
// If game.spawnedMunchkins is greater than 5:  
if (game.spawnMunchkins \> 5) {  
// Set spawnMunchkinsGoal state as successful…  
game.setGoalState(spawnMunchkinsGoal, True);  
}  
// If both other goals are completed.  
if (spawnMunchkinsGoal.success) {  
if (defeatScoutsGoal.success) {  
// Set dontTouchGoal state as successful…  
game.setGoalState(dontTouchGoal, true);  
}  
}  
}

game.setActionFor(“munchkin”, “spawn”, onSpawn);  
game.setActionFor(“munchkin”, “defeat”, onDefeat);  
game.setActionFor(“scout”, “defeat”, onDefeat);

while (true) {  
checkGoals();  
}

---

<div class="post-metadata">

**Author:** ![Sydney\_Barger](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/sydney_barger/32/18106_2.png) [@Sydney\_Barger](https://discourse.codecombat.com/u/Sydney_Barger)\
**Post date:** [January 4, 2021, 1:26am UTC](https://discourse.codecombat.com/t/dont-touch-them-javascript/25970/39 "2021-01-04T01:26:33Z")

</div>

this is what i currently have an it keeps getting stuck and not letting me complete the level. im not sure what i’m doing wrong.

 ![Screenshot 2021-01-03 at 8.26.00 PM](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/3X/c/2/c277f75a76f13d0133256b362e9ffcd7688ac4af.jpeg)

---

<div class="post-metadata">

**Author:** ![Eric\_Tang](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/eric_tang/32/15310_2.png) [@Eric\_Tang](https://discourse.codecombat.com/u/Eric_Tang)\
**Post date:** [January 4, 2021, 1:28am UTC](https://discourse.codecombat.com/t/dont-touch-them-javascript/25970/40 "2021-01-04T01:28:44Z")

</div>

i haven’t done this level in javascript but look at your indentation, it needs some fixing

---

<div class="post-metadata">

**Author:** ![Sydney\_Barger](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/sydney_barger/32/18106_2.png) [@Sydney\_Barger](https://discourse.codecombat.com/u/Sydney_Barger)\
**Post date:** [January 4, 2021, 1:29am UTC](https://discourse.codecombat.com/t/dont-touch-them-javascript/25970/41 "2021-01-04T01:29:56Z")

</div>

so do you have any suggestions on what to indent?

---

<div class="post-metadata">

**Author:** ![Eric\_Tang](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/eric_tang/32/15310_2.png) [@Eric\_Tang](https://discourse.codecombat.com/u/Eric_Tang)\
**Post date:** [January 4, 2021, 1:30am UTC](https://discourse.codecombat.com/t/dont-touch-them-javascript/25970/42 "2021-01-04T01:30:36Z")

</div>

umm every line after an if statement and the line under while(true){

[Previous page](https://discourse.codecombat.com/t/dont-touch-them-javascript/25970.md?page=1)
