创建数组值的字符串查询可以通过以下步骤实现:
function searchArray(query) {
var myArray = ["apple", "banana", "orange"];
var index = myArray.indexOf(query);
if (index !== -1) {
return "The string value '" + query + "' is found at index " + index + " in the array.";
} else {
return "The string value '" + query + "' is not found in the array.";
}
}
var result = searchArray("banana");
console.log(result);
输出结果将是:"The string value 'banana' is found at index 1 in the array.",表示在数组中找到了字符串值"banana",并且它在数组中的索引位置是1。
腾讯云相关产品和产品介绍链接地址:
领取专属 10元无门槛券
手把手带您无忧上云