Ask coding questions

← Back to all posts
I dont know how to make this work
DSACharlie (2)

I'm trying to make a sign up and log in button but I cant figure out how to do something that is defined with a function but I'm trying to use a function in another function above the function but I need those functions to stay there but I cant do that

Answered by PattanAhmed (1014) [earned 5 cycles]
View Answer
Commentshotnewtop
PattanAhmed (1014)

@DSACharlie Hi Charlie,
Can I ask what are you planning to make right now?
Thanks!

DSACharlie (2)

@PattanAhmed Im trying to make kind of like my own website and im naming it CharlieCo

PattanAhmed (1014)

@DSACharlie So, you can't make a login page?
Thanks!

DSACharlie (2)

@PattanAhmed Well I am having to type in something that I hadn't typed before and I'm not able to move anything

PattanAhmed (1014)

@DSACharlie Check this Repl and check
https://repl.it/@PattanAhmed/Check-this-code-here#index.html

Hope this helps
Please mark my answer if this helps

SixBeeps (2907)

There's a lot going on here.
You have function declarations inside of function declarations, which I'm guessing is not what you're going for. Try separating them into their own thing.
Also, you're using a lot of local variables. Make them global by using declaring them outside of the functions.

SixBeeps (2907)

@DSACharlie Looks like you didn't declare your variables globally

SixBeeps (2907)

@DSACharlie At the very top, set them to something.

DSACharlie (2)

@SixBeeps can you show me how to do that?

SixBeeps (2907)

@DSACharlie Something like

let username = "";
let password = "";

etc.

SixBeeps (2907)

@DSACharlie It declares a variable, like function declares a function.

Coder100 (7006)

Ok, so basically you didn't declare any of those variables. Here's your fixed and cleaned code:
click me

Coder100 (7006)

Hi! You forgot a closing brace.

DSACharlie (2)

or usernameenter or passwordenter

DSACharlie (2)

and it says that username or password is not defined

DSACharlie (2)

the problem is in script.js