有人可以告诉我以下5个练习有什么问题吗?我正确地完成了其他95个练习,但是在重复时这些练习总是出错。
您能告诉我为什么这些练习错了吗?5个练习中有什么错误?
有人告诉我1个练习中有错误会在其余练习中引发错误。
// Exercise One: In this exercise you will create a variable called 'aboutMe'
// This variable should be assigned a new object
// In this object create three key:value pairs
// The keys should be: 'name', 'city', 'favoriteAnimal'
// The values should be strings associated with the keys.
// return the variable 'aboutMe'
var aboutMe = {
name: 'Brian',
city: 'Columbus',
favoriteAnimal: 'Dog'
};
return (aboutMe);
}
function exerciseTwo(animal) {
// Exercise Two: In this exercise you will be given an object called 'animal'
// Create a new variable called 'animalName'
// Accessing the animal object, assign the 'animalName' variable to the 'latinName' key on the object.
// return the animalName variable.
}
let animalName = {
animalName: latinName
}
return (animalName)
function exerciseThree(userObject) {
// Exercise Three: In this exercise you will be given an object called 'userObject'
// The phonne number for this user is incorrect!
// reassign the 'phoneNumber' key to the value: '(951)867-5309'
// return the userObject
userObject: phoneNumber.(951) 867 - 5309;
}
function exerciseFour(value) {
let greaterThanFive = true;
// In this exercise, you will be given a variable, it will be called: value
// You will also be given a variable named: greaterThanFive
// Using an 'if' statement check to see if the value is greater than 5. If it is, re-assign greaterThanFive the boolean true.
if (value > 5) {
value = greaterThanFive
}
// Please write your answer in the line above.
return greaterThanFive;
}
function exerciseFive(name) {
let isSondra = false;
// In this exercise, you will be given a variable, it will be called: name
// You will also be given a variable named: isSondra
// Using an 'if' statement check to see if the name is equal to the string 'Sondra'. If it is, re-assign isSondra the boolean true.
if (name = isSondra) {
return true
} else {
false
}
// Please write your answer in the line above.
return isSondra;
}
让您开始...。
在第一个练习中,在return
之后有一个额外的闭合花括号。此外,您只能在函数内使用return
,而您的代码不在其中。相反,您必须将变量记录到控制台或显示为alert
或以其他方式显示。
var aboutMe = {
name:'Brian',
city:'Columbus',
favoriteAnimal:'Dog'
};
console.log(aboutMe);