Page 1 of 1

Javascript Mission 1 - Alternative solution doubt

PostPosted: Sun May 06, 2018 10:10 pm
by Edzk
Hello World!
I succesfully solved the first mission, it was very easy, but it left me with soume doubts. I found 1 or 2 alternative solutions, pretty much identical & still very very basic.
However they only worked when I saved the paged and edited it on on the notepad, while they did not when editing through Chrome's "inspect".

Could anyone suggest me why is that?

PM me if you're not sure what I'm talking about, it's pretty hard expressing myself clearly while not spoilering

Thx

Re: Javascript Mission 1 - Alternative solution doubt

PostPosted: Tue May 08, 2018 9:56 am
by supertoto
Hi,
You should be able to write javascript code in the console. Then you can redefine the function of your choice.

Re: Javascript Mission 1 - Alternative solution doubt

PostPosted: Wed May 09, 2018 5:16 am
by Edzk
supertoto wrote:Hi,
You should be able to write javascript code in the console. Then you can redefine the function of your choice.


Hello, thanks for your answer, I'm not sure I've understood what you're saying though. I'm 100% newbie.
Could you please articulate it a little more?

What I tried to do was to edit some code while inspecting the page but it did not work. When I did the exact same thing using notepad it worked perfectly fine. The same happened with every JS mission I tried using this technique on.
I really don't get where's the difference

Thanks

Re: Javascript Mission 1 - Alternative solution doubt

PostPosted: Wed May 09, 2018 7:35 am
by supertoto
When you use the element inspector, that doesn't concern javascript, but only the DOM elements (DOM for Document Object Model), that is to say here the HTML code.

But...
When you open the inspector, you can also access a console mode. Here you can write JS code, and it will be interpreted in the current page. So, instead of modifying the script itself in the inspector (that doesn't work), you can use the console to replace the previous c... function.

I think this is not a spoiler if a write :
function c....(...) { ... the new code ... }
because I think it's still more difficult than the normal way.

Don't worry about the message: "undefined", this is the return value.

If you write :
function hello() {return "hello"}
you get undefined

but if after that you write :
hello()
you get "hello"