JavaScript - 如何打印数组内的输入?

JavaScript - How do I print an input inside an array?

我已经尝试了很多方法来解决这个问题,但总是 returns undefined。我应该怎么做才能解决这个问题?

function printThreeFavoriteColours() {
  const colours = [];
  const colorUserFav1 = prompt("type your first favorite color");
  const colorUserFav2 = prompt("now, type your second favorite color");
  const colorUserFav3 = prompt("finally, type your third favorite color");
  
  colours.push = (colorUserFav1, colorUserFav2, colorUserFav3);
  console.log(colours);
}
colors.push( //put whatever you want to be pushed here)

你差不多明白了,你只需要从你的例子中删除 =

function printThreeFavoriteColours() {
  const colours = [];
  const colorUserFav1 = prompt("type your first favorite color");
  const colorUserFav2 = prompt("now, type your second favorite color");
  const colorUserFav3 = prompt("finally, type your third favorite color");

  colours.push(colorUserFav1, colorUserFav2, colorUserFav3);
  console.log(colours);
}