V
V
vvmgev2014-08-01 10:46:35
css
vvmgev, 2014-08-01 10:46:35

Where is the error in javascript?

var asa = {
   age:15,
  name:"gexam",
  color:"sev",
}
var bas = +prompt("mi ban", "");
document.write(asa.bas)

Answer the question

In order to leave comments, you need to log in

3 answer(s)
L
lnked, 2014-08-01
@vvmgev

works like this:

var asa = {
  age: 15,
  name: "gexam",
  color: "sev"
}
var bas = prompt("mi ban", "");
document.write(asa[bas])

O
OlegTar, 2014-08-01
@OlegTar

var asa = {
   age:15,
  name:"gexam",
  color:"sev",
}

Commas after the last value are not understood by older Internet Explorers.
Plus before prompt is not an error, but a cast to a number.
var bas = +prompt("mi ban", "");
document.write(asa.bas)

writing goes to the bas variable, and reading the bas property of the asa object

A
akrom123, 2014-08-01
@akrom123

var asa = {
   age:15,
  name:"gexam",
  color:"sev",
}
asa.bas = prompt("mi ban", ""); // вроде так дожно быть
document.write(asa.bas) // Это неправильно, prompt это не текст чтобы в html пихать

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question