在JavaScript中,你可以创建自定义函数来输出提示信息和数组元素。这里是一个示例,展示了如何定义一个名为customFunction
的函数,该函数接收输入参数并返回一些预设的提示以及数组的一个随机元素:
// 定义自定义函数
function customFunction(data, gv, cache, inputs) {
// 提示信息
console.log("这是自定义函数的输出提示:");
// 获取输入数组
const inputArray = inputs.array;
// 如果有数组,随机选择一个元素
if (inputArray) {
const randomIndex = Math.floor(Math.random() * inputArray.length);
const randomElement = inputArray[randomIndex];
console.log(`随机选取的数组元素是: