Interactive Programming Forums
Login
Register
Home
Questions/Snippets/Exercises
Unanswered
Tags
Ask a Question
Post a Code Snippet
Post an Exercise
Welcome to Interactive Programming Forums, where you can ask questions, receive answers from other members of the community, post code snippets and post exercies.
All categories
Ruby
(3)
Python
(10)
PHP
(7)
Perl
(2)
SQL
(8)
Javascript
(6)
HTML
(20)
CSS
(4)
jQuery
(0)
XML
(3)
Code Snippets
(1)
Exercises
(4)
Other
(9)
What is wrong in this JavaScript code?
+6
votes
What is wrong in this Javascript code? It appears under the Arrays tutorial, question 10
var beverages=new Array("Coke","Sprite","7-UP","Pepsi"); document.write(beverages.unshift("Diet Coke"));
I saw a post dated 2 weeks ago where popo12(6,110 points) said he/she had answered the question but the response does not show up. HELP!!
posted
12 years
ago
in
Javascript
by
Heidi Vincent
(
3,970
points)
1 Answer
+2
votes
Hi,
Can you give me more details about the issue?
I've tried the exercise and got the following result:
js> var beverages=new Array("Coke","Sprite","7-UP","Pepsi");
var beverages=new Array("Coke","Sprite","7-UP","Pepsi");
js> document.write(beverages.unshift("Diet Coke"));
5
Is your output different from mine?
answered
12 years
ago
by
codeadmin
(
113,880
points)
Thanks, you have the right code but I think you have the wrong answer. Isn't the "unshift" supposed to place Diet Coke at the beginning of the array? In any case, when I input the code it just repeats itself three times but does not yield a result or allow me to move on to the next question. So I am stuck.
I copied your code into the exercise box and didn't get anything out of it. no answer no nothing.
I am having the same issue, no response other than repeat itself. Some previous instructions showed same behaviour. All in javascript tutorial. Is there any answer from the site?
Related questions
+6
votes
1
answer
why is this code wrong
posted
12 years
ago
in
HTML
by
rahmahnerkhan
(
1,580
points)
programming
goal
+8
votes
1
answer
there is a bug with RegExp exam in Javascript
posted
12 years
ago
in
Javascript
by
manlink2000
(
5,280
points)
+10
votes
0
answers
Can I have a code for a preloader on javascript or css
posted
12 years
ago
in
Javascript
by
resila01
(
1,700
points)
+7
votes
1
answer
I cannot get Ques 7 in the JavaScript Function Tutorial to work? Help!
posted
12 years
ago
in
Javascript
by
Heidi Vincent
(
3,970
points)
+11
votes
1
answer
what is java?
posted
13 years
ago
in
Javascript
by
Idalecio Joaquim
(
710
points)