Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/469.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
不确定如何在JavaScript中使用反勾号_Javascript_Google Chrome_Firefox_Atom Editor - Fatal编程技术网

不确定如何在JavaScript中使用反勾号

不确定如何在JavaScript中使用反勾号,javascript,google-chrome,firefox,atom-editor,Javascript,Google Chrome,Firefox,Atom Editor,这是我第一次使用backticks,我无法在FireFox或Chrome中使用我的函数。这是我的密码: function makeLetter(fName, lName) { return `Dear ${fName} ${lName}, How are you today?`; } 当我输入makeLetter(hello,world)时,我得到以下错误: ReferenceError: hello is not defineddebugger eval code:1:1 <

这是我第一次使用backticks,我无法在FireFox或Chrome中使用我的函数。这是我的密码:

function makeLetter(fName, lName) {
  return `Dear ${fName} ${lName},
    How are you today?`;
}
当我输入
makeLetter(hello,world)
时,我得到以下错误:

ReferenceError: hello is not defineddebugger eval code:1:1
<anonymous> debugger eval code:1
ReferenceError:hello未定义debugger评估代码:1:1
调试器评估代码:1

我做错了什么?

反勾号使用得很好。JavaScript解释器抱怨,因为它不知道
hello
world
。您将它们作为变量传入,需要将它们作为字符串传入。像这样:

函数makeLetter(fName,lName){
返回'Dear${fName}${lName},
你今天好吗;
}

log(makeLetter('John','Doe'))
makeLetter(“你好”,“世界”)它正在查找未定义的变量或fn。如果您没有设置变量,请将它们设置为字符串。非常感谢!现在我明白多了。我也会确保使用你的console.log提示!