Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
i am trying to check what items are in array.
this is my code
var fruits=['banana','orange','lemon'];
fruits.splice(0,1,'apple');
for (i=0;i<=fruit.length;i++)
{
alert('The fruits are' + fruits[i]);
};
Somehow it's not Working.
please tell me where i am doing wrong.
thanks.
Have you mistakenly added fruit.length or you have written code like this?
syntax;-
array.splice(index,howmany,item1,.....,itemX)
index->positon from/to u want to ad and remove items
howmany->how many item u want add/remove
item->item list(for more than pne seprate it by comma)
also:-
please add s after fruit in for loop
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
In an app I'm working on, I'd found that updating the DOM by rewriting a new value to innerHTML doesn't give the expected result.
I typed the following command in the DevTools console:
document.querySelector('main-app').shadowRoot.querySelector('.unitslist').innerHTML = '<unit-bar>1</unti-bar><unit-bar>2</unti-bar>'
With the following result:
<unit-bar>1<unit-bar>2</unit-bar></unit-bar>
You have a typo in your strings. You open with <unit-bar>, but close with </unti-bar>. The closing tags are therefore probably ignored by the browser and it guesses where they should be, resulting in the difference you see.
so , you can solve to avoid overwriting: -
1. get the content of the div and that add the current value to update and the existing values
DOMElem.innerHTML = DOMElem.value + (value to be updated)
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 years ago.
Improve this question
Below is the code I currently using which I need to round the end result to 2 decimals.Can someone help me figure out what I did wrong.
total = panjang*ht+hf;
document.getElementById("ototal").innerHTML =eval(total(toFixed(2)));
The variable total is a number, not a function.
You should use toFixed function like this
total.toFixed(2)
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
I am trying a very basic javascript map example
var map1 = {'myKey1':11, 'mykey2':22};
var t = map1['mykey1'];
alert(t);
But the alert always gives me 'undefined', it should give me '11'
please guide what i am doing wrong
You have a spelling mistake there mate, notice that in your map1 object there is no mykey1 key actually, there is a myKey1 key however, containing a capital K
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
I'm trying to find a way to output an array in alphabetical order as well as the length by a window alert, or alternatively any way for the user to be able to see it, when they're in the browser.
Here is the little bit of code:-
var vehicles = ["Car", "Bus", "Train", "Boat","Plane"];
vehicles.sort();
As well as:-
vehicles.length();
It is vehicles.length not vehicles.length()
You can output in an alert
alert( vehicles.length );
or log into the console
console.log( vehicles.length );
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 9 years ago.
Improve this question
I have created the javascript based demonstration and now I want to hide an image on click in certain condition only.
$("#clear").click(function(){
if ($('#image').is(":visible") && ('#image2').is("hidden")) {
$("#image").hide();
};
});
As you can see my code is not right, so I want to know how to format my code properly. I couldn't find the right way to write multiple conditions in one string. Thanks in advance.
The problem is that you forget to add $ (jQuery) to your second condition and selector hidden is incorrect, should be :hidden:
if ($('#image').is(":visible") && $('#image2').is(":hidden"))