Diamonddolphin26
Badges: 7
Rep:
?
#1
Report Thread starter 1 year ago
#1
I'm stuck on the Idea Silver badge on the first functions. This is what I typed down:
initiate();
function lifeSupportCheck() {
initiate();
}

Where have I gone wrong?
0
reply
Igotanidea
Badges: 5
Rep:
?
#2
Report 1 year ago
#2
It's ridiculous how unhelpful the course is... I emailed them and their response it is supposed to be harder than bronze...... Shame they can't do their jobs and make a constructive piece of kit. I'll post the answer when i guess it right
0
reply
Igotanidea
Badges: 5
Rep:
?
#3
Report 1 year ago
#3
initiate();
function lifeSupportCheck () {
//
}
1
reply
Hannah_ lawler
Badges: 2
Rep:
?
#4
Report 1 year ago
#4
Do you know the answer to the one which says:Call the function you just wrote, in the same way you called initiate,then press ‘run code’
0
reply
Hannah_ lawler
Badges: 2
Rep:
?
#5
Report 1 year ago
#5
(Original post by Igotanidea)
initiate();
function lifeSupportCheck () {
//
}
Do you know the answer too this one :
Attached files
0
reply
winterscoming
Badges: 19
Rep:
?
#6
Report 1 year ago
#6
(Original post by Hannah_ lawler)
Do you know the answer to the one which says:Call the function you just wrote, in the same way you called initiate,then press ‘run code’
(Original post by Hannah_ lawler)
Do you know the answer too this one :
Firstly, a function in programming is basically a named block of instructions - the task gives you one of those called lifeSupportCheck.

The block of instructions is everything in-between those { curly } brackets, although of course the { and } in your lifeSupportCheck is basically empty aside from the // comment. Therefore it's a function which actually wouldn't do anything if it were used, but that doesn't matter. The function can still exist and do-nothing when the program actually uses it

However, the code in your task only creates ('defines') the function (that's what the curly brackets are doing - i.e. linking the block of instructions with the name) - the code doesn't actually use that function. So even if it did contain any instructions, the program would never run those. The phrase 'call the function'. is just a programmer's way of saying "use this function as if it were a single instruction in your program to run it".

'calling' a function is a matter of using its name and the (rounded brackets), and ending with a semicolon. Your task mentions "the same way you called initiate" as a clue that you already have an example line in your program which calls the initiate function by doing this:
Code:
initiate();
One last point on where to put the line - Programming languages' instructions flow downwards in-sequence, just like Written English, so the position in your program where you call the function is important. It needs to happen after the closing-curly-bracket } because the code needs to have finished the sequence of actually creating/defining the whole function before it's possible to actually call it

(Just remember the order that you do things matters, like when making a cup of tea, you can't pour hot water before the kettle has finished boiling)
1
reply
Hannah_ lawler
Badges: 2
Rep:
?
#7
Report 1 year ago
#7
Not trying to be rude, but could you shorten that please ?
0
reply
Hannah_ lawler
Badges: 2
Rep:
?
#8
Report 1 year ago
#8
(Original post by winterscoming)
Firstly, a function in programming is basically a named block of instructions - the task gives you one of those called lifeSupportCheck.

The block of instructions is everything in-between those { curly } brackets, although of course the { and } in your lifeSupportCheck is basically empty aside from the // comment. Therefore it's a function which actually wouldn't do anything if it were used, but that doesn't matter. The function can still exist and do-nothing when the program actually uses it

However, the code in your task only creates ('defines') the function (that's what the curly brackets are doing - i.e. linking the block of instructions with the name) - the code doesn't actually use that function. So even if it did contain any instructions, the program would never run those. The phrase 'call the function'. is just a programmer's way of saying "use this function as if it were a single instruction in your program to run it".

'calling' a function is a matter of using its name and the (rounded brackets), and ending with a semicolon. Your task mentions "the same way you called initiate" as a clue that you already have an example line in your program which calls the initiate function by doing this:
Code:
initiate();
One last point on where to put the line - Programming languages' instructions flow downwards in-sequence, just like Written English, so the position in your program where you call the function is important. It needs to happen after the closing-curly-bracket } because the code needs to have finished the sequence of actually creating/defining the whole function before it's possible to actually call it

(Just remember the order that you do things matters, like when making a cup of tea, you can't pour hot water before the kettle has finished boiling)
Not trying to be rude, but could you shorten that ?
0
reply
winterscoming
Badges: 19
Rep:
?
#9
Report 1 year ago
#9
(Original post by Hannah_ lawler)
Not trying to be rude, but could you shorten that ?
Sorry for the long answer! It's useful to know what the code means anyway


And an example of calling a function which is this (including the name, brackets and semicolon at the end) :
Code:
initiate();
so it's just asking you to 'call' your function, which is lifeSupportCheck();
0
reply
Hannah_ lawler
Badges: 2
Rep:
?
#10
Report 11 months ago
#10
(Original post by winterscoming)
Sorry for the long answer! It's useful to know what the code means anyway


And an example of calling a function which is this (including the name, brackets and semicolon at the end) :
Code:
initiate();
so it's just asking you to 'call' your function, which is lifeSupportCheck();
Thank you xx
1
reply
toepeach1997
Badges: 6
Rep:
?
#11
Report 11 months ago
#11
does anyone know the answer for

$review = $_POST['review'];

insertIntoDatabase($review);
0
reply
MiniFestSam
Badges: 1
Rep:
?
#12
Report 11 months ago
#12
(Original post by toepeach1997)
does anyone know the answer for

$review = $_POST['review'];

insertIntoDatabase($review);
i was stuck on this forever. in your notepad theres a code with escape tags. you just gotta follow that. can't remember exactly but i think the answer is something like

$review = escape_tags($review);
and just put that in the blank line between the two you already have.
its not much but play around with it and you'll get it
0
reply
toepeach1997
Badges: 6
Rep:
?
#13
Report 11 months ago
#13
(Original post by MiniFestSam)
i was stuck on this forever. in your notepad theres a code with escape tags. you just gotta follow that. can't remember exactly but i think the answer is something like

$review = escape_tags($review);
and just put that in the blank line between the two you already have.
its not much but play around with it and you'll get it
It worked thank you!!!
0
reply
toepeach1997
Badges: 6
Rep:
?
#14
Report 11 months ago
#14
$myFormData = $_POST['comments'];

insertIntoDatabase($myFormData);


Does anyone know how to sanitise
0
reply
RobTheGoblin
Badges: 4
Rep:
?
#15
Report 6 months ago
#15
(Original post by Diamonddolphin26)
I'm stuck on the Idea Silver badge on the first functions. This is what I typed down:
initiate();
function lifeSupportCheck() {
initiate();
}

Where have I gone wrong?
here is the correct answer for anyone who needs it

initiate();

function lifeSupportCheck() {

//initiate(lifeSupportCheck);

}
1
reply
BonnieBunBuns
Badges: 0
Rep:
?
#16
Report 5 months ago
#16
I'm stuck on the loop part, can someone help me with that?
0
reply
BonnieBunBuns
Badges: 0
Rep:
?
#17
Report 5 months ago
#17
Nevermind, I completed it, i don't need help with it ;-;
Last edited by BonnieBunBuns; 5 months ago
0
reply
tinyminy13
Badges: 11
Rep:
?
#18
Report 5 months ago
#18
(Original post by toepeach1997)
$myFormData = $_POST['comments'];

insertIntoDatabase($myFormData);


Does anyone know how to sanitise
The answer to sanitise the variable before it gets inserted into the database
should be:

$myFormData = escape_tags($myFormData);
insertIntoDatabase($myFormData)

You only need to replace the first line with the escape_tags variable and replace $message to $myFormData.
Hope this helps!
0
reply
Mehrin_09
Badges: 0
Rep:
?
#19
Report 4 weeks ago
#19
Has anyone done level 6 on the maker badge (sliver activation). The part with the sound blocks. I really need help!! T-T
0
reply
X

Quick Reply

Attached files
Write a reply...
Reply
new posts
Back
to top
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

Are you travelling in the Uni student travel window (3-9 Dec) to go home for Christmas?

Yes (50)
29.59%
No - I have already returned home (23)
13.61%
No - I plan on travelling outside these dates (38)
22.49%
No - I'm staying at my term time address over Christmas (15)
8.88%
No - I live at home during term anyway (43)
25.44%

Watched Threads

View All
Latest
My Feed