第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

如何正確顯示我的數(shù)組?初學(xué)者里面

如何正確顯示我的數(shù)組?初學(xué)者里面

富國滬深 2023-06-29 22:46:31
你好嗎?現(xiàn)在,我正在用 Javascript 學(xué)習(xí)數(shù)組。我已經(jīng)完成了一個(gè)將數(shù)組內(nèi)容顯示到 HTML 文件中的函數(shù),但我只收到“未定義”。首先,我嘗試修改“contenido”內(nèi)部的代碼,但我只將“字符”接收到0位置,例如:contenido += "<div id=d"+posicion+">Titulo: " +系列標(biāo)題[0]。它給我返回了“D”,德克斯特。我究竟做錯(cuò)了什么?這是我的代碼。/*Creating a class to structure the information of a TV show by saving the title, theme, array with the main actors and saving the favorite actor in the array.*/class SerieTV {    constructor (titulo, tematica, actoresPrincipales){        var arrayActores = new Array();        this.titulo=titulo;        this.tematica=tematica;        this.actores=actoresPrincipales;/* Adding a function to generate a random favorite actor.*/            this.generaActorFavorito = function(){            var long = actoresPrincipales.length;            let calc = Math.floor(Math.random()*(long));           arrayActores = actoresPrincipales[calc];           console.log(arrayActores);        }            }}/* Creating 3 series, the 1st with 2 actors, 2nd with 3 and 3rd with 4. Later, adding it to a new array called "total_series."*/var show01= new SerieTV('Dexter ',  'Drama ', ['Michael C Hall ' ,'Jennifer Carpenter']);show01.generaActorFavorito();var show02 = new SerieTV('Samurai Gourmet' ,  'Cocina' ,  ['Naoto Takenaka' ,'Tetsuji Tamayama' , 'Honami Suzuki '] );show02.generaActorFavorito();var show03 = new SerieTV ('Breaking Bad ', 'Drama ', ['Aaron Paul ','Bryan Cranston ', 'RJ Mitte ', 'Anna Gunn ']); show03.generaActorFavorito();console.log("-------------------------");var total_series = new Array();total_series.push(show01);total_series.push(show02);total_series.push(show03);console.log(total_series);console.log("-------------------------");
查看完整描述

2 回答

?
幕布斯6054654

TA貢獻(xiàn)1876條經(jīng)驗(yàn) 獲得超7個(gè)贊

要訪問類的成員,請使用點(diǎn)表示法語法。

contenido += "<div id=d"+posicion+">Titulo: "+serie.titulo+"<br> Temática: "+serie.tematica+" <br> Actor Favorito: "+serie.actoresPrincipales+" <br> Actores: "+serie.actores+" <br><br>";

generaActorFavorito另外,在這個(gè)語句的方法中,arrayActores = actoresPrincipales[calc]您將一個(gè)數(shù)組重新分配為一個(gè)沒有意義的值,您可以簡單地執(zhí)行var arrayActores;而不是var arrayActores = new Array();


查看完整回答
反對 回復(fù) 2023-06-29
?
慕慕森

TA貢獻(xiàn)1856條經(jīng)驗(yàn) 獲得超17個(gè)贊

好的,問題解決了。我解決了刪除方括號的問題。謝謝你們??!

contenido += "<div id=d"+posicion+">Titulo: "+serie.titulo+"<br> Temática: "+serie.tematica+" <br> Actor Favorito: "+serie.actoresPrincipales+" <br> Actores: "+serie.actores+" <br><br>";



查看完整回答
反對 回復(fù) 2023-06-29
  • 2 回答
  • 0 關(guān)注
  • 162 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號