我的JavaScript代码的语法错误是什么?

时间:2017-05-24 19:58:45

标签: javascript

有人请告诉我以下代码有什么问题吗?我是javascript的新手,我知道某处有一个丢失的逗号。谢谢。

i = 1:12
((i - 2) %% 12) + 1
[1] 12  1  2  3  4  5  6  7  8  9 10 11

5 个答案:

答案 0 :(得分:2)

bakeTime和bakeTemp都丢失了逗号。 mixInstructions函数也是如此,但它还没有必要。

答案 1 :(得分:2)

您在bakeTimebakeTemp之后缺少逗号,并且您的函数中遗漏了this " and bake at " + bakeTemp + " for " + bakeTime

var cake = {
  firstIngredient: "milk",
  secondIngredient: "eggs",
  thirdIngredient: "cakemix",
  bakeTime: 22,
  bakeTemp: 420,
  mixingInstructions: function() {
    return "Add " +
    this.firstIngredient + " to " + this.secondIngredient + " and stir with " + this.thirdIngredient + " and bake at " + this.bakeTemp + " for " + this.bakeTime + " minutes.";
  }
};

console.log(cake.mixingInstructions())

答案 2 :(得分:2)

对@Stephen L的跟进,

你忘了在import pandas as pd Data = pd.DataFrame({'L1': [1,2,3,4,5], 'L2': [6,7,3,5,6], 'ouptput':[10,11,12,13,14]}) Data

之后加上加号

答案 3 :(得分:2)

返回“添加”

后,您也错过了“+”

答案 4 :(得分:2)

您有以下3个错误:

  1. 之后缺少逗号   烘烤时间:22   bakeTemp:420
  2. +
  3. 之后遗失"Add"
  4. this.中缺少bakeTemp而返回字符串中缺少bakeTime

    return "Add " + this.firstIngredient + " to " + this.secondIngredient + " and stir with " + this.thirdIngredient + " and bake at " + this.bakeTemp + " for " + this.bakeTime + " minutes.";

  5. 
    
        var cake = {
          firstIngredient: "milk",
          secondIngredient: "eggs",
          thirdIngredient: "cakemix",
          bakeTime: 22,
          bakeTemp: 420,
          mixingInstructions: function() {
            return "Add "+ 
    this.firstIngredient + " to " + this.secondIngredient + " and stir with " + this.thirdIngredient + " and bake at " + this.bakeTemp + " for " + this.bakeTime + " minutes.";
          }
        };
    console.log(cake.mixingInstructions());