const adFormats = {
leaderboard: {
sizes: [
[728, 90],
],
},
rectangle: {
sizes: [[320, 250], [300, 250], 'fluid'],
},
halfpage: {
sizes: [[300, 600], [320, 250], [300, 250]],
},
};
这就是出错的地方
Object.keys(adFormats).forEach(key => {
adFormats[key].sizes.forEach(size => {
if (typeof size !== 'string') {
companionSizes += `${size[0]}x${size[1]}`;
}
companionSizes += '|';
});
companionSizes += ',';
});
// expected output: '728x90,320x250|300x250,300x600|320x250|300x250'
我想用 join() 和/或 map() 使这个更干净。为了防止使用前导或尾随分隔符。还有一些更干净的代码。
POPMUISE
相关分类