Сообщество IT-специалистов
Ответы на любые вопросы об IT
Профессиональное развитие в IT
Удаленная работа для IT-специалистов
function findReceipt(){ for( key in getReceipt ){ for( prop in getReceipt[key]){ return prop == 'info' ? (`${key}: ${getReceipt[key][prop].slice(0)}`) : ''; } } }
Uncaught RangeError: Maximum call stack size exceeded
function findReceipt(){ for( key in getReceipt ) { if (!getReceipt.hasOwnProperty(key)) continue; for( prop in getReceipt[key]){ if (!getReceipt[key].hasOwnProperty(prop)) continue; return prop == 'info' ? (`${key}: ${getReceipt[key][prop].slice(0)}`) : ''; } } }
function findReceipt(){ for( key in getReceipt ){ for( prop in getReceipt[key]){ return prop == 'info' ? (`${key}: ${getReceipt[key][prop].slice(0)}`) : ''; } } } let timerId = setTimeout(function getInfo() { timerId = setTimeout(getInfo(), 10); }, 1000); console.log(getInfo());
function receipt() { const arrayReceipt = [{ 'Lavash': { info: 'Big Cheese', price: 15000, }, 'Hot-dog': { info: 'mini', price: 8500, }, 'Cola': { info: '1.5 L', price: 9000, }, }, { 'Milk': { info: '1 L', price: 8500, }, 'Sugar': { info: '1 kg', price: 7000, }, }, { 'Cola': { info: '1 L', price: 6500, }, 'Fanta': { info: '1.5 L', price: 9000, }, 'Lipton': { info: '1.2 L', price: 5000, }, 'Nestle': { info: '10 L', price: 8500, }, },]; const count = Math.floor(Math.random() * arrayReceipt.length); return arrayReceipt[count]; }; let getReceipt = receipt(); let key let prop function findReceipt(){ for( key in getReceipt ){ for( prop in getReceipt[key]){ return prop == 'info' ? (`${key}: ${getReceipt[key][prop].slice(0)}`) : ''; } } } console.log(`${getInfo}, ${getInfo}, ${getInfo}`) : '';
( function f( r, t ) { setTimeout( f, t, r, t ); const s = Object.entries( r() ) .map( ( [ k, v ] ) => k + ': ' + v.info ) .join( '\n' ); console.log( s ); } ) ( receipt, 1000 );