Java Script function does not work [closed] - javascript

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
var Structure[undefined]
function run{
Structure[0]
}
function setStructure(structure){
Structure[0]=structure
}
setStructure(House);
function House(){
//nothing
}
Why is the return of House() function not in Structure[0]?
It is for a Minecraft PE mod.

I suppose you intended this:
function run{
Structure[0]() // <--- notice the parentheses.
}
Without the parentheses, the function run does not do anything. It just references the function, without invoking it.

Related

what is the work of .id in this given function [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 9 hours ago.
Improve this question
what is .id in this given function
function getSelected() {
let answer = undefined;
answerEls.forEach((answerEl) => {
if (answerEl.checked) {
answer = answerEl.id;
}
});
return answer;
}
I tried to find what is .id by console .log but it does does not show any value

Display specific row from API in react [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 months ago.
Improve this question
Iam trying to write a map function to show all the item in API
ScreenShoot of code to display the items
and this is the console log of the item that fetch from API
I got Error for the map function that isn't working what is the solution
Thank you
It's a little hard to tell from the picture.
But if I understood correctly you have no return.
Note that you can only have one div in the return.
export default function Feed(props) {
const array1=props.graphDataa.value
return (
<div>
{
postsArr.map(item=> (whatever you want to display...))
}
</div>
Your div is closed in the opening tag - "taskcolorblack-div"
You need return value from method listmap like this: return map1;
In render function u can call like this return (<>{listmap().join()}</>)

can not convert this string to object [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 months ago.
Improve this question
I can not convert this string to object.Why I am getting this error? please help.
onSignup(data:any){
localStorage.setItem('users',JSON.stringify(data));
let users = JSON.parse(localStorage.getItem('users'));
}
Try using function onSignup(data: any) { localStorage.setItem('users', JSON.stringify(data)); let users = JSON.parse(localStorage.getItem('users') as string); }
If you are using typescript you can't pass a string | undefined when a string is expected.

How to set variable of image src and use in javascript function? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
The community is reviewing whether to reopen this question as of 2 years ago.
Improve this question
So if i have some codes like this
If(sceneA){document.getElementById("divA").src="A.png";}
If(document.getElementById("divC")=="A.png"){document.getElementById("divB").src="B.png";}//And alot of codes here
How can I use a var to shorten strings like
document.getElementById("divA").src="A.png"
document.getElementById("divB").src="B.png"
so i can use them both inside (IF) and {function}
As they have to repeat quite a few times in the codes.
Thanks alot!
That's exactly what functions are for.
Define a function for repeating blocks of code as follows:
function setSrc(divName, imgName){
document.getElementById("div"+divName).src = imgName+".png";
}
function srcEquals(divName, imgName){
return (document.getElementById("div"+divName).src == imgName+".png");
}
Then you can replace your code with this:
if(sceneA){setSrc("A","A");}
if(srcEquals("C", "A")){setSrc("B","B");}

Why is my external script not included and how to change inner HTML [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I am working on a basic website and I'm trying to use JS to make "video-navigator"
The thing is:
my external script is not being included
So this is my HTML for including my JS
<script src="script.js"></script>
Click here for the entire site
You have a few issues with this. Firstly you're trying to set the innerHTML incorrectly which is failing. Secondly you're using a reserved word for a function (new). In the pop function I've commented out your incorrect bit and added a correct version. I've also renamed your function to new_renamed so that it works.
alert("working");
function pop()
{
alert("INVALID INPUT");
//HTMLDivElement("content") innerHTML = "";
document.getElementById('content').innerHTML = '';
}
function old()
{
alert("INVALID INPUT");
}
function new_renamed()
{
alert("INVALID INPUT");
}
Above will log.

Categories

Resources