我是编程新手(已经在Codecademy上学过一些JS课程).我正在尝试创建一个简单的脚本来确定,如果给出一个包含扑克游戏结果的电子表格,谁应该付钱给谁.我打开了Google Apps脚本,并编写了以下内容以开始使用:
function addplayerstoArray(numplayers) {
var playerArray = [];
for (i=0; i<numplayers; i++) {
playerArray.push(i);
}
}
addplayerstoArray(7);
console.log(playerArray[3])
Run Code Online (Sandbox Code Playgroud)
我们的想法是创建一个包含其中玩家总数的数组.运行代码时,我认为它会在控制台上打印"3".但什么都没发生.它说
"ReferenceError:"console"未定义."
A)我不了解Google Apps脚本控制台如何处理打印,以便我可以看到我的代码是否完成了我想要的内容?
B)代码有问题吗?
当我打开一个新的外壳时,我得到:
\n\nLast login: Sun Mar 23 10:14:46 on ttys000\n\n-bash: \xc2\xa0: command not found\nRun Code Online (Sandbox Code Playgroud)\n\n我不完全确定如何弄清楚那里发生了什么,因为它不完全清楚它正在谈论哪个命令。
\n\n它可能在 .bashrc 文件中吗?
\n\nHISTSIZE=10000\nHISTFILESIZE=20000\n\nexport CLICOLOR=1\nexport LSCOLORS=ExFxCxDxBxegedabagacad\nexport PS1="\\[\\e[01;32m\\]\\h \\[\\e[01;34m\\]\\W \\$(parse_git_branch)\\[\\e[01;34m\\]$\\[\\e[00m\\] "\n\nexport PYTHONSTARTUP=/Users/JimShook/.pythonstartup\nexport WORKON_HOME=$HOME/.virtualenv\nsource /usr/local/bin/virtualenvwrapper.sh\n\n# Setting PATH for Python 2.7\n# The orginal version is saved in .bash_profile.pysave\nPATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"\nexport PATH\n\nfunction parse_git_dirty {\n [[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"\n}\n\nfunction parse_git_branch {\n git branch --no-color 2> /dev/null | sed -e \'/^[^*]/d\' -e "s/* \\(.*\\)/[\\1$(parse_git_dirty)]/"\n}\n\nPATH=$PATH:/usr/local/rvm/bin # …Run Code Online (Sandbox Code Playgroud)