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.
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.
how do you find the value
I copied what says above about the coin and pasted it below.
then i changed the place that says coin to gem and the value from 2 to 10.
I don’t get why it still doesn’t work
It says I ran out of time
if(item.type == "gem" && item.value == 10 )
AND in javascript is “&&”
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”
It still says I ran out of time
This is my code for the spring thunder level.
// 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);
}
}
This is the code i wrote for the spring thunder without the excess words that are on the pad at the beggining.
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);
}
}
It worked I just needed faster boots thank you.
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
I use chrome radchenko
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
do you mean like this
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 ^
ok i understand mr Radchenko