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've got an array:
test = [{'id':'73','name':'bar', 'contact': [{'name':'barFoo','tel':'3333'}]},{'id':'45','name':'foo', 'contact':[]}]
I try to get contact.tel in first object with 'id':'73'
I'm using find method :
let contactTel = test.find(x => x.id === '73').contact.tel;
but it dosen't work. What I'm doing wrong ?
it should be like this
const test = [{'id':'73','name':'bar', 'contact': [{'name':'barFoo','tel':'3333'}]},{'id':'45','name':'foo', 'contact':[]}]
let contactTel = test.find(x => x.id === '73').contact[0].tel;
console.log(contactTel)
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 3 months ago.
Improve this question
i want to replace all the "_" occurrences from an array like this (TASK_1,TASK_2,TASK_3).
I receive this from the back-end and i cannot use the replace all because the project doesn't support es2021. I need to display the array like this (TASK 1,TASK 2, TASK 3).
I tried this method:
formatWithoutUnderScore(valueToFormat:any) {
return valueToFormat.map((value:any) => value.replace(/_/g, ' '));
}
and the used it:
this.formatWithoutUnderScore(this.totalTasks);
But it does nothing :(
Can someone help?
this.totalTasks = this.formatWithoutUnderScore(this.totalTasks);
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 6 years ago.
Improve this question
I'm creating a site and i needed to do some js. I'm not that good with it but tought i would figer it out. Not. I created a for loop but it does not run.
function order(user,product){
var index;
for(var i = 0; i<users.lenght; i++){
if(user == users[i]){
index = i;
break;
}
}
var budget = budgets[index];
alert(budget);
}
the creation of the users and budgets arrays are done with php and after checking with alert() it was how it should be.
Can anyone help me please?
lenght is spelt length. The misspelt property does not exist, so it undefined, which is equivalent to 0.
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'm trying to use a function inside another function. Right now, setPanodatas() appears as not defined:
function setPoints(obj, prop) {
// Some code
if (unzippedNewPanodatas)
unzippedNewPanodatas = unzippedNewPanodatas.slice(scope.panodatas.length)
_.each(unzippedNewPanodatas, function(point) {
var Panodata = AV.Object.extend('PanoramaData')
var panodata = new Panodata()
obj[prop].push(setPanodatas(panodata.toJSON(), point))
})
}
function setPanodata(panodata, point) {
panodata.set('index', point.index)
panodata.set('x', offsetX(point.x))
panodata.set('y', offsetY(point.y))
panodata.set('roomModelId', scope.pano.id)
panodata.set('panoDataRotate', 0)
panodata.set('differentLayout', false)
panodata.set('panoCount', 6)
panodata.set('type', 'VRoom')
console.log('PANODATA', panodata)
return panodata
}
Why isn't setPanodata() visible inside setPoints()?
It is because setPanodatas is undefined.
Rather it is setPanodata, you added s.
function setPanodata(panodata, point)
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));