所以我试图从单独的node.js文件中列出的数组中自动检索随机条目
功能代码
var replies = require('./replies');
function followed(event) {
var name = event.source.name;
var flname = event.source.screen_name;
var myArray = [replies];
var item = myArray[(Math.random()*myArray.length)|0];
var followtweet = '@' + flname + item;
if(flname != "UserName") {
tweetIt(followtweet);
console.log('\n@' + flname + ' Followed You');
console.log('\nYou Tweeted:\n ' + followtweet);
} else {
console.log(' Interferance From Another Bot! \n');
}
}
外部数组
module.exports = {
followedone: 'one',
followedtwo: 'two',
followedthre: 'three',
replyone: ' one',
replytwo: ' two',
replythre: ' three',
}
当我运行此功能并且该功能运行时我得到了这个
@LandscapesLucid Followed You
You Tweeted:
@LandscapesLucid[object Object]
Waiting For The Next Action
我不确定为什么它只显示[object Object]而不是像数组一样的两个或三个
答案 0 :(得分:0)
你能尝试改变吗?
pages = {
Australia: AustraliaPage,
Canada: CanadaPage,
...
};
<super-tabs scrollTabs="true" *ngIf="tabsLoaded">
<super-tab *ngFor="let tab of tabs" [root]="pages[tab.countryName]" title="tab.countryName"></super-tab>
</super-tabs>
到此?
var item = myArray[(Math.random()*myArray.length)|0];