Spring Thunder Javascript


#1

I don’t understand how do you do this.

A blue gem has a value of 10.
// Collect if item.type is equal to “gem”
// AND item.value is equal to 10.


#2

how do you find the value


#3

I copied what says above about the coin and pasted it below.


#4

then i changed the place that says coin to gem and the value from 2 to 10.


#5

I don’t get why it still doesn’t work


#6

It says I ran out of time


#7

if(item.type == "gem" && item.value == 10 )

AND in javascript is “&&”


#8

In javascript, “and” is used as “&&.” Also, to set the gem’s value for a given number (in your case, 10), use the code “item.value == 10”


#9

It still says I ran out of time


#10

This is my code for the spring thunder level.


#11

// Certain coins and gems attract lightning.
// The hero should only grab silver coins and blue gems.

while (true) {
var item = hero.findNearestItem();
// A silver coin has a value of 2.
// Collect if item.typ is equal to “coin”
// AND item.value is equal to 2.
if (item.type == “coin” && item.value == 2) {
hero.moveXY(item.pos.x, item.pos.y);
}
// A blue gem has a value of 10.
// Collect if item.type is equal to “gem”
// AND item.value is equal to 10.
if(item.type == “gem” && item.value == 10 ) {
hero.moveXY(item.pos.x, item.pos.y);
}
}


#12

This is the code i wrote for the spring thunder without the excess words that are on the pad at the beggining.


#13

while (true) {
var item = hero.findNearestItem();
if (item.type == “coin” && item.value == 2) {
hero.moveXY(item.pos.x, item.pos.y);
}
if(item.type == “gem” && item.value == 10 ) {
hero.moveXY(item.pos.x, item.pos.y);
}
}


#14

It worked I just needed faster boots thank you.


#15

your code is hard to read.

Edit your post with code, select code and click button

it will automatically make it looks good

also maybe you computer or browser is too slow for CodeCombat.
Fastest I think is Chrome


#16

I use chrome radchenko


#17

while (true) {
var item = hero.findNearestItem();
// A silver coin has a value of 2.
// Collect if item.typ is equal to “coin”
// AND item.value is equal to 2.
if (item.type == “coin” && item.value == 2) {
hero.moveXY(item.pos.x, item.pos.y);
}
// A blue gem has a value of 10.
// Collect if item.type is equal to “gem”
// AND item.value is equal to 10.
if(item.type == “gem” && item.value == 10 ) {
hero.moveXY(item.pos.x, item.pos.y);Preformatted text


#18

do you mean like this


#19

select code ----> click that button.

while (true) {
var item = hero.findNearestItem();
   // A silver coin has a value of 2.
   // Collect if item.typ is equal to "coin"
   // AND item.value is equal to 2.
if (item.type == "coin" && item.value == 2) {
hero.moveXY(item.pos.x, item.pos.y);
}
   // A blue gem has a value of 10.
   // Collect if item.type is equal to "gem"
   // AND item.value is equal to 10.
if(item.type == "gem" && item.value == 10 ) {
hero.moveXY(item.pos.x, item.pos.y);

code looks like this ^


#20

ok i understand mr Radchenko