Untitled conversation
- User
function getTerjualText(aTag) { const elements = aTag.querySelectorAll('*'); let text = ''; for (const element of elements) { if (element.textContent && element.textContent.includes('Terjual')) { text = element.textContent; console.log("text " + text); } } return text; } let terjualText = getTerjualText(aTag); console.log("Terjual: " + terjualText);In most cases it prints these kind of lines:
text KACAMATA PRIA SPORT FRAME AKSESORIS MINUS PHOTOCROMIC POLARIZED ANTI SILAU ANTI RADIASI FRAME POLYCARBONATE INDOOR BERSEPEDA BERKENDARA MENGEMUDI MEMANCING TERBARU KEREN KEKINIAN WANITA UNISEXRp143.89649 TerjualKOTA TANGERANG text 49 Terjual Terjual: 49 TerjualThe first line of text are a concatenation of the texts from the all elements. I just want to get the "49 Terjual". Sure it prints "Terjual: 49 Terjual" but why the first console.log shows texts from several elements?
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.