Click here to Skip to main content
15,393,863 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
there is error in my code

so, i want to print movie number 4 and movie number 1 in my browser wihtin the paragraph of id movie1 , when button suspense is clicked but it is not working . please help

What I have tried:

let movies={"evergreen","titanic","tarzan","casino royale" , "welcome to jungle","battle of los angeles"  };

  let sus={"movies[3]","movies[0]"}

  let one =document.getElementById("movie1");

  function susPense()
    one.innerHTML= sus;
<p id="movie1">suspense</p>
Updated 10-Jun-21 1:00am
OriginalGriff 6-Jun-21 12:07pm
"It's not working" is one of the most useless problem descriptions we get: it tells us absolutely nothing about the problem. We don't know if you get an error message, or the wrong data, or even that that code compiles successfully!
Remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type to work with.
So tell us what happens when you run that code, what you expected to happen, how you checked what happened. Help us to help you!
Use the "Improve question" widget to edit your question and provide better information.
[no name] 6-Jun-21 12:10pm
so you can't find error in my code right?
OriginalGriff 6-Jun-21 12:30pm
How would I know?
You show us almost nothing, tell us "it don't work" but give us no details - what are we supposed to tell you?

Think about it: you go for a drive, and the car breaks down.
You ring the garage, say "it broke" and hang up.
How long do you think you will be waiting until the garage arrives with the right parts?
At a place they don't know, to fix a car they don't know the make or model of, for a person they have no idea who you are, to fix a fault when they have no idea what "broke"? Are you out of petrol? Did it catch fire? Did the door mirror fall off? They have no idea ... and your question leaves us in exactly the same position ...

Help us to help you!
[no name] 6-Jun-21 12:35pm
compiler is showing that susPense() the function is not defined
[no name] 6-Jun-21 12:38pm
if you know js then you will see in my code that i declared it right or if there is another way t declare the function in js please tell
[no name] 6-Jun-21 12:13pm
or the topic is "there is an error" not "it's not working" , so please rather finding error in question please find error in code , if you can .
Richard MacCutchan 6-Jun-21 12:26pm
So you still expect us to guess what error you are talking about and where it occurs. If you really want help with your problem then please provide proper details. We have no idea what you see when you try to run this, or what the circumstances are.
OriginalGriff 6-Jun-21 12:34pm
Remind me to get a new tin-foil hat, will you? This one is clearly defective ... :D
Richard MacCutchan 6-Jun-21 12:44pm
... and a Hazmat suit. :)

The audacity of some people amazes me clearly this kid lacks one of the basic behavioral features of social interactions graditude the appreciation for someone else’s time even if they both didn’t have a clue about java they still took the time to listen to u and try to help and the kids mly thing u gave back was self entitled sarcasm i guess some people have no understanding of manners or respect both of u glentlemen handled this kids ignorance with Class whats so common about sense
function susPense()
one.innerHTML= sus;

compiler is showing that susPense() the function is not defined
I suspect is is actually saying that "suspense" is not defined: suspense != susPense.
[no name] 6-Jun-21 12:49pm
while posting the question i also posted the paragraph and the button tag of html but when i posted it show suspense which is a id of the paragraph
Richard MacCutchan 6-Jun-21 12:57pm
No it is not, go and look again, carefully, at the difference between the two words.
[no name] 6-Jun-21 12:59pm
Uncaught ReferenceError: susPense is not defined
see this
Richard MacCutchan 6-Jun-21 15:02pm
Please stop and think. Look at your code, and the error message, and show us the complete details. Nothing you have posted up to now looks like the real issue.
[no name] 8-Jun-21 14:16pm
ohh , i found it , it should be straight bracket while declaring the array not the curly bracket , please from next time ownwards care for solution not for the type of the question fr
Richard MacCutchan 8-Jun-21 14:21pm
And you please think about your problem, and provide a proper detailed explanation.
[no name] 8-Jun-21 14:23pm
have you really work on javascript
cause i don't think so
staying here to waste other people time
Richard MacCutchan 8-Jun-21 14:24pm
Well you posted the question. And by the way, you are not paying for this, so please stop giving us orders.
[no name] 8-Jun-21 14:29pm
i am not giving orders
just saying before you comment something , just stay with the problem ,like i stayed figure out it on my own
Richard Deeming 9-Jun-21 5:15am
Asking questions is a skill. Read your question again, without access to any of your code - there is clearly not enough information there for anyone else to be able to answer it.

If someone asks you to provide more information, start by providing the information requested, rather than ranting and insulting the person who is trying to help you.

Similarly, if someone posts an answer which is a guess based on the incomplete information provided, go back and update your question with the missing information, rather than assuming the person answering doesn't know anything and is trying to waste your time.

Your comments here are unacceptable. You owe both Richard MacCutchan and OriginalGriff an apology.
[no name] 8-Jun-21 14:31pm
and also before you go to any conclusion to the question make sure you even know the programming language .
Richard MacCutchan 8-Jun-21 14:47pm
You too, dude.
Javascript is case sensitive: JavaScript Syntax[^]
[no name] 6-Jun-21 12:56pm
ohh thank you , i didn't know about that
[no name] 6-Jun-21 13:09pm
Uncaught ReferenceError: susPense is not defined
see this , this is the error you want to know
[no name] 8-Jun-21 14:17pm
gfn, pos
OriginalGriff 8-Jun-21 14:21pm
Do you want to try that again in some comprehensible language?
[no name] 8-Jun-21 14:22pm
it was just to tell you that you are good for nothing
OriginalGriff 8-Jun-21 14:26pm
Oh I see!
That is correct - we don't charge you, we are all volunteers.
So yes, we are all good, and for nothing.
[no name] 8-Jun-21 14:34pm
don't indulge others with yourself , maybe they are more capable than you :)
when declaring array straight bracket should be use not curly bracket

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900