关于功能的脚本

问题描述 投票:-1回答:1

我很难理解这部分代码:

"use strict";

let v = ["sept","huit","neuf","dix","valet","dame","roi","as"];
let c = ["pique","coeur","trèfle","carreau"];

function creerCarte( v, c){



}

let test = creerCarte("neuf", "trèfle");
console.log(test["valeur"]);  // must show "neuf" on console
console.log(test["couleur"]);  // must show "trèfle" on console

我不明白通过变量调用函数:

console.log(test["valeur"]);

什么是["valeur"],它用于什么?

javascript function call
1个回答
-1
投票

您需要完成creerCarte函数才能返回一个对象。但是我不知道你的代码需要做什么。

test [“valeur”]表示获取名为“valeur”的测试对象的属性。

例如:

test = {value:'something'}

你会用test ['valeur']找回'某事'。

© www.soinside.com 2019 - 2024. All rights reserved.