Silver idea award Watch

emmakola
Badges: 8
Rep:
?
#1
Report Thread starter 3 months ago
#1
Stuck on the robotics section maker activation
0
reply
blogbyreviews
Badges: 20
Rep:
?
#2
Report 3 months ago
#2
replying to this thread for the same answer
0
reply
blogbyreviews
Badges: 20
Rep:
?
#3
Report 3 months ago
#3
loops
Attached files
0
reply
emmakola
Badges: 8
Rep:
?
#4
Report Thread starter 3 months ago
#4
Put
Rooms[i]
On line 7
0
reply
blogbyreviews
Badges: 20
Rep:
?
#5
Report 3 months ago
#5
was this the part that you were stuck on?
Attached files
0
reply
emmakola
Badges: 8
Rep:
?
#6
Report Thread starter 3 months ago
#6
Yes it is, when you have to pass the correct sound into the array. I know you do [1] but I can't remember how you call the array
Last edited by emmakola; 3 months ago
0
reply
winterscoming
Badges: 18
Rep:
?
#7
Report 3 months ago
#7
(Original post by emmakola)
Yes it is, when you have to pass the correct sound into the array. I know you do [1] but I can't remember how you call the array
I'm not quite clear what you mean by 'call the array'? Do you mean read an item of data from it? or add an item of data into it? or change an item at a position?

(nitpick: The word 'call' usually means 'do a thing' or 'execute an instruction' -- for example you'll often read/hear people say 'call a function' meaning running/executing the code inside that function.. so that doesn't really make sense with an array, which is just a list of items -- The kinds of things you'd normally do with an array would be: add/remove an item, modify (overwrite/change) some existing item, read an item, read its length, etc. )


Anyway, an array has a name just like any other variable. In fact, an array works just like a list-of-variables.

The only extra thing you need to do is add the square-brackets and your position number to the end, and then you can do all the normal things that you'd do with any other variable. e.g. https://repl.it/repls/FeminineExperiencedDecimals
Code:
var myArray = [ "dog", "cat", "bird" ];
myArray[0] = "fish";
console.log(myArray[0]);
The name of the array on its own means 'the complete array' (so the name of the array helps you do things like access/add/remove an item or get its length). The square brackets [ ] are for selecting a specific position, so you need the number for that position.

the square brackets can use just a plain number for the position - e.g [1], or they can be given another variable which contains a number (Like the 'counter' which you'd use in a "for"-loop -- e.g. [ i ] )

https://www.w3schools.com/js/js_arrays.asp
https://developer.mozilla.org/en-US/..._Objects/Array
Last edited by winterscoming; 3 months ago
0
reply
adamr747
Badges: 2
Rep:
?
#8
Report 3 months ago
#8
Aigghh??
0
reply
emmakola
Badges: 8
Rep:
?
#9
Report Thread starter 3 months ago
#9
(Original post by winterscoming)
I'm not quite clear what you mean by 'call the array'? Do you mean read an item of data from it? or add an item of data into it? or change an item at a position?

(nitpick: The word 'call' usually means 'do a thing' or 'execute an instruction' -- for example you'll often read/hear people say 'call a function' meaning running/executing the code inside that function.. so that doesn't really make sense with an array, which is just a list of items -- The kinds of things you'd normally do with an array would be: add/remove an item, modify (overwrite/change) some existing item, read an item, read its length, etc. )


Anyway, an array has a name just like any other variable. In fact, an array works just like a list-of-variables.

The only extra thing you need to do is add the square-brackets and your position number to the end, and then you can do all the normal things that you'd do with any other variable. e.g.
Code:
var myArray = [ "dog", "cat", "bird" ];
myArray[0] = "fish";
print(myArray[0]);
The name of the array on its own means 'the complete array' (so the name of the array helps you do things like access/add/remove an item or get its length). The square brackets [ ] are for selecting a specific position, so you need the number for that position.

the square brackets can use just a plain number for the position - e.g [1], or they can be given another variable which contains a number (Like the 'counter' which you'd use in a "for"-loop -- e.g. )

https://www.w3schools.com/js/js_arrays.asp
https://developer.mozilla.org/en-US/..._Objects/Array
Thank ouu I'll see if that works.
0
reply
emmakola
Badges: 8
Rep:
?
#10
Report Thread starter 3 months ago
#10
This code doesn't work are you able to help?

That's not it. You must:
[ul]
[li]Loop through soundBlocks[/li]
[li]call the playSound() function[/li]
[li]Pass the correct sound from your sound array into it[/li]
[/ul]
TRY AGAIN

for (i=0;i<movementBlocks.length;i++ ) {
doMovement(movementBlocks[i])
}
for (i=0;i<sounfBlocks.length;i++){
playSound(soundBlocks[i]);
}
soundBlocks[1]=happyBeep;
print(soundBlocks[1]);
var soundBlocks = [crash,happyBeep,whistle];
0
reply
winterscoming
Badges: 18
Rep:
?
#11
Report 3 months ago
#11
(Original post by emmakola)
This code doesn't work are you able to help?

[/font][/size]
[ul]
[li][/font][/size][/li]
[li][/font][/size][/li]
[li][/font][/size][/li]
[/ul]

[/b][/font][/size][/font][/size]

for (i=0;i<movementBlocks.length;i++ ) {
doMovement(movementBlocks[i])
}
for (i=0;i<sounfBlocks.length;i++){
playSound(soundBlocks[i]);
}
soundBlocks[1]=happyBeep;
print(soundBlocks[1]);
var soundBlocks = [crash,happyBeep,whistle];
You didn't mention the error(s) you're getting, but the obvious problem I can see is that you're attempting to use your soundBlocks array before you've even created it. (The 'var soundBlocks' line is the instruction which actually creates it - until that point it doesn't exist so the lines above that won't work if they try to use it before it exists..)

Remember that JavaScript reads things from top-to-bottom just like humans. Think of it like a 'recipe' perhaps; your program is a sequence of instructions which happen in the order you describe them. You can't put icing on a cake before you've mixed the ingredients together and baked it in the oven. The same applies here, if you're using a variable in a program then the variable needs to be created first. Just as with a recipe, sure you always consider the order in which things are happening!

Otherwise, if there are any different problems, it helps to describe what you're seeing (errors/unexpected behaviour) and what you'd expect instead..
0
reply
emmakola
Badges: 8
Rep:
?
#12
Report Thread starter 3 months ago
#12
(Original post by winterscoming)
You didn't mention the error(s) you're getting, but the obvious problem I can see is that you're attempting to use your soundBlocks array before you've even created it. (The 'var soundBlocks' line is the instruction which actually creates it - until that point it doesn't exist so the lines above that won't work if they try to use it before it exists..)

Remember that JavaScript reads things from top-to-bottom just like humans. Think of it like a 'recipe' perhaps; your program is a sequence of instructions which happen in the order you describe them. You can't put icing on a cake before you've mixed the ingredients together and baked it in the oven. The same applies here, if you're using a variable in a program then the variable needs to be created first. Just as with a recipe, sure you always consider the order in which things are happening!

Otherwise, if there are any different problems, it helps to describe what you're seeing (errors/unexpected behaviour) and what you'd expect instead..
Okay I'll change the order and put var soundBlocks at the top
I'm not good with JavaScript I normally use python. You may like the IDEA Duke of York challenge, if you complete the silver star can you include it on a CV.
0
reply
emmakola
Badges: 8
Rep:
?
#13
Report Thread starter 3 months ago
#13
(Original post by winterscoming)
You didn't mention the error(s) you're getting, but the obvious problem I can see is that you're attempting to use your soundBlocks array before you've even created it. (The 'var soundBlocks' line is the instruction which actually creates it - until that point it doesn't exist so the lines above that won't work if they try to use it before it exists..)

Remember that JavaScript reads things from top-to-bottom just like humans. Think of it like a 'recipe' perhaps; your program is a sequence of instructions which happen in the order you describe them. You can't put icing on a cake before you've mixed the ingredients together and baked it in the oven. The same applies here, if you're using a variable in a program then the variable needs to be created first. Just as with a recipe, sure you always consider the order in which things are happening!

Otherwise, if there are any different problems, it helps to describe what you're seeing (errors/unexpected behaviour) and what you'd expect instead..
Okay I'll change the order and put var soundBlocks at the top
I'm not good with JavaScript I normally use python. You may like the IDEA Duke of York challenge, if you complete the silver star can you include it on a CV.
0
reply
winterscoming
Badges: 18
Rep:
?
#14
Report 3 months ago
#14
(Original post by emmakola)
Okay I'll change the order and put var soundBlocks at the top
I'm not good with JavaScript I normally use python. You may like the IDEA Duke of York challenge, if you complete the silver star can you include it on a CV.
Python is definitely a much nicer language! Although if you're comfortable with Python, then there are quite a few similarities too, and I'm sure you'll get used to JavaScript once all of the braces and semicolons start to look more comfortable.

The IDEA thing seems like a good... idea.. to get people interested in writing code, I hope you're enjoying it!

(And thanks, although I already have a job working in JavaScript among other things, but I'm always glad to see things like that to get people interested and learning more about programming )
Last edited by winterscoming; 3 months ago
0
reply
emmakola
Badges: 8
Rep:
?
#15
Report Thread starter 3 months ago
#15
It worked thank you, had to just put all my added code under var soundBlocks.
1
reply
Camanero_An
Badges: 1
Rep:
?
#16
Report 3 months ago
#16
what are you meant to do for fuction 2?
Attached files
0
reply
emmakola
Badges: 8
Rep:
?
#17
Report Thread starter 3 months ago
#17
(Original post by Camanero_An)
what are you meant to do for fuction 2?
That's correct how you have done

lifesSupportCheck()

You've made a mistake on line 8 you've put two }}

Just remove the } from line 8 and keep the one on line 9

Then it should run
0
reply
Camanero_An
Badges: 1
Rep:
?
#18
Report 3 months ago
#18
(Original post by emmakola)
That's correct how you have done

lifesSupportCheck()

You've made a mistake on line 8 you've put two }}

Just remove the } from line 8 and keep the one on line 9

Then it should run
It say "Pass your room array into the lifeSupportOn() function! Type lifeSupportOn(rooms[i]) inside your loop, then press `Run Code`."
Attached files
0
reply
HorusOG
Badges: 5
Rep:
?
#19
Report 2 months ago
#19
"That's correct how you have done

lifesSupportCheck()

You've made a mistake on line 8 you've put two }}

Just remove the } from line 8 and keep the one on line 9

Then it should run"


Wrong. The engine will not allow for it - you need to perform a specific task. I myself have struggled with this one, because when you follow the instructions it does not even work.

Anyone got answers for how to pass through this part? I really just want to move on at this point, IDEA's coding activities really are not the best sadly.
0
reply
shadhora
Badges: 1
Rep:
?
#20
Report 1 month ago
#20
hello i try to put one of the previous code and i didn't really work could someone help fix it and understand y this doesn't work ??

var soundBlocks = [crash,happyBeep,whistle];
for (i=0;i<movementBlocks.length;i++ ) {
doMovement(movementBlocks[i])
}
for (i=0;i<soundBlocks.length;i ){
playSound(soundBlocks[i]);
}
soundBlocks[1]=happyBeep;play(soundBlocks[1]);
Last edited by shadhora; 1 month ago
0
reply
X

Quick Reply

Attached files
Write a reply...
Reply
new posts
Latest
My Feed

See more of what you like on
The Student Room

You can personalise what you see on TSR. Tell us a little about yourself to get started.

Personalise

Do you have a food intolerance or allergy?

Yes - a food intolerance (88)
14.52%
Yes - a food allergy (63)
10.4%
Yes - an autoimmune disorder (i.e coeliac, colitis) (15)
2.48%
Yes - I have an intolerance and allergy (16)
2.64%
No (424)
69.97%

Watched Threads

View All
Latest
My Feed