Ask coding questions

← Back to all posts
Changing java script values to upperCase isn't working
MikeJMS8910

I am making an input value a variable in my java script code. When I use the value.upperCase() when I run it the text isn't upper case it just says "function toUpperCase() { [native code] }" but not in the error just as the header

Answered by Coder100 [earned 5 cycles]
View Answer
Voters
Michaael8910
MikeJMS8910
Comments
hotnewtop
Coder100

Are you sure you called it? Something like this works:

MikeJMS8910

@Coder100 no I called it back in html
<a id="variable">text</a>

Coder100

well now you really need to send your repl I have no idea what you are doing
@MikeJMS8910

MikeJMS8910

@Coder100
heres the link to the code https://repl.it/@JMSScienceFair/ProjectRemade#index.html
on line 299 I change the value to upper case and then on line 311 I call the code. When you test it and fill out all of the info on controls then you will be able to see the problem

ReferenceError

@MikeJMS8910

to uppercase is a method. replace it with .toUpperCase()

MikeJMS8910

@DotExe well now im getting this error
TypeError: Cannot set property 'innerHTML' of null
at solveSq (/:305:55)
at controlsCheck (/:258:11)
at HTMLButtonElement.onclick (/:112:166)

Coder100

you dont have an element with id Gype. Make sure it exists. @MikeJMS8910

Coder100

change Gype (line 305) to GType @MikeJMS8910

ReferenceError

@MikeJMS8910 There is no element with a id of Gype.

MikeJMS8910

@Coder100 how can I do that

MikeJMS8910

@Coder100 ohhh I see but the error is still there

MikeJMS8910

@DotExe sorry typo but the error is still there

Coder100

just change ur code to:

@MikeJMS8910

ReferenceError

@MikeJMS8910 change the element's id html wise: id or change the js document.getElementById("GType")

Coder100

its case sensitive @MikeJMS8910

Coder100

you have Gtype but it needs to be GType @MikeJMS8910

SixBeeps

Please link some code

MikeJMS8910

@SixBeeps the code I used was just
variable.toUpperCase()

SixBeeps

@MikeJMS8910 Looks like Coder100 and DotExe got you on this one, but for future reference, when providing code, provide as much as you can. Sometimes the problem lies with something other than the line itself.

MikeJMS8910