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 was trying to make some object into objects , but there's a problem with my syntax.
That's the code:
var friends = {
bill : {
firstName:"Bill",
lastName:"Gates",
number:00158965478
},
steve :{
firstName:"Steve",
LastName:"Jobs"
number:00125688977
},
Joe: {
firstName:"Joe",
LastName:"Erabti",
number:0021625804429
}
};
You forgot the comma after last names of Jobs.. So its suppose to be like this:
var friends = {
bill : {
firstName:"Bill",
lastName:"Gates",
number:00158965478
},
steve :{
firstName:"Steve",
LastName:"Jobs", //<-- You previously forgot it here
number:00125688977
},
Joe: {
firstName:"Joe",
LastName:"Erabti",
number:0021625804429
}
};
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 7 months ago.
Improve this question
So i have this code
router.get('/invite/:invitecode', async(res,req) => {
return console.log(req.params)
if(!req.params.invitecode) {
return res.render('404')
}
if(!req.user) {
res.redirect(`/login?state=invite/${req.params.invitecode}`)
} else {
res.render('join')
}
})
And when I go to
http://localhost:3000/invite/fs
It is supposed to return fs as a param, but instead, it console.logs undefined
Why is this happening?
It does not work because you are accessing the Response object, you should flip the arguments
from:
async(res,req)
to
async(req,res)
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 11 months ago.
Improve this question
i am uisang this code:
Class Addition {
constructor () {
}
add (a = 1, b = 1) {
console.log(a+b)
}
}
but it geeve aan error
Uncaught SyntaxError: Unexpected identifier
Syntax is wrong, class should be in lowercase:
class Addition {
constructor () {
}
add (a = 1, b = 1) {
console.log(a+b)
}
}
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
I've was given this is a multiple choice JS question. I said [], I just wanted to check if this is correct and if not why?
Consider this if statement:
if (loggedIn) {
body_classes = ["user-active"];
}
Which pair of characters in this code is optional?
""
()
{}
[]
The optional characters are the braces {}
if (loggedIn) {
body_classes = ["user-active"];
}
is the same as
if (loggedIn)
body_classes = ["user-active"];
If you remove the square brackets then body_classes becomes a string rather than an array.
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
I have this array declared as
rowData = []
I want to update this array with a forloop but it keeps replacing the values instead of updating it. I guess I'm doing something wrong.
rowDataDefs(){
for (let to of this.detailedOrders){
console.debug(to)
this.rowData = [
{table_no: to.table.tableNo, order_no: to.orderNo, date_time: to.table.createdDate }
]
}
}
rowDataDefs(){
for (let to of this.detailedOrders){
console.debug(to)
this.rowData.push(
{table_no: to.table.tableNo, order_no: to.orderNo, date_time: to.table.createdDate });
}
}
You need to use array.push() instead of replacing the same index(0th index) value every time.
rowDataDefs(){
for (let to of this.detailedOrders){
console.debug(to)
this.rowData.push(
{
table_no: to.table.tableNo,
order_no: to.orderNo,
date_time: to.table.createdDate
}
)
}
return this.rowData;
}
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 7 years ago.
Improve this question
I've used this :
String.Prototype.left = function left(count){
return this.substr(0,count);
}
And apply it this way :
var string = "Hello Stack!";
console.log(string.left(5));
And the console tells me :
TypeError: example.left is not a function
console.log(example.left(5));
How can I fix it? And where is the problem?
String.prototype.left = function(index){
return this.substring(0,index);
}
var str = "Hello World";
console.log(str.left(5));