The Student Room Group

Stuck on Idea Silver badge Maker Activation

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?

Scroll to see replies

Reply 1

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

Reply 2

initiate();
function lifeSupportCheck () {
//
}

Reply 3

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’

Reply 4

Original post by Igotanidea
initiate();
function lifeSupportCheck () {
//
}

Do you know the answer too this one :

Reply 5

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 :smile:

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:

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)

Reply 6

Not trying to be rude, but could you shorten that please ?

Reply 7

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 :smile:

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:

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 ?

Reply 8

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 :smile:


And an example of calling a function which is this (including the name, brackets and semicolon at the end) :

initiate();

so it's just asking you to 'call' your function, which is lifeSupportCheck();

Reply 9

Original post by winterscoming
Sorry for the long answer! It's useful to know what the code means anyway :smile:


And an example of calling a function which is this (including the name, brackets and semicolon at the end) :

initiate();

so it's just asking you to 'call' your function, which is lifeSupportCheck();


Thank you xx

Reply 10

does anyone know the answer for

$review = $_POST['review'];

insertIntoDatabase($review);

Reply 11

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 :smile:

Reply 12

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 :smile:

It worked thank you!!!

Reply 13

$myFormData = $_POST['comments'];

insertIntoDatabase($myFormData);


Does anyone know how to sanitise

Reply 14

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);

}

Reply 15

I'm stuck on the loop part, can someone help me with that?

Reply 16

Nevermind, I completed it, i don't need help with it ;-;
(edited 4 years ago)

Reply 17

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!

Reply 18

Has anyone done level 6 on the maker badge (sliver activation). The part with the sound blocks. I really need help!! T-T

Reply 19

Original post by BonnieBunBuns
Nevermind, I completed it, i don't need help with it ;-;

im stuck o dat:smile:

Quick Reply