Click here to Skip to main content
15,880,469 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:

JavaScript
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;
  }
HTML
<p id="movie1">suspense</p>
Posted
Updated 10-Jun-21 1:00am
v2
Comments
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

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
 
Share this answer
 
JavaScript
function susPense()
{
one.innerHTML= sus;
}
suspense

Quote:
compiler is showing that susPense() the function is not defined
I suspect is is actually saying that "suspense" is not defined: suspense != susPense.
 
Share this answer
 
Comments
[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
Javascript is case sensitive: JavaScript Syntax[^]
 
Share this answer
 
Comments
[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
when declaring array straight bracket should be use not curly bracket
 
Share this answer
 

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



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