javascript - 需要变量A来声明变量B,但是需要变量B来声明变量A
问题描述
我正在制作一个工具来制作一个新的谷歌文档并将其通过电子邮件发送给我的老师以获取某个主题,但是我的变量“主题”需要包含文档链接,这意味着我需要在声明变量主题之前创建文档,但是,为了知道给文档起什么名字,我需要访问存储在变量 Subjects 中的信息。有什么建议么?我的javascript在下面。
function doGet() {
return HtmlService.createHtmlOutputFromFile('Index.html');
}
function customDoc(subject) {
var formattedDate = Utilities.formatDate(new Date(), Session.getScriptTimeZone(), 'M/d/yyyy');
var subjects = {
'math': {
email: 'teacher@example.com',
preSubject: 'math for '
},
'la': {
email: 'teacher@example.com',
preSubject: 'la for '
},
'science': {
email: 'teacher@example.com',
preSubject: 'science for '
},
'is': {
email: 'teacher@example.com',
preSubject: 'I&S for '
},
'spanish': {
email: 'teacher@example.com',
preSubject: 'Español para '
message: 'Español para ' + formattedDate + 'This is supposed to be where the link to the google doc is, so this is where the paradox comes in. '
}
};
console.log('Today: ' + formattedDate);
console.log('Subject: ' + subject);
console.log(subjects[subject]);
GmailApp.sendEmail(subjects.email, subjects.preSubject, subjects.message)
}
解决方案
推荐阅读
- go - 从 Windows 10 交叉编译到树莓派 CGO_ENABLED = 1
- vba - VBA 在条件格式方面遇到问题 excel
- google-apps-script - 当带有公式的单元格的值发生变化时,是否有触发功能?
- python - 按数据框中的字符串过滤并添加单独的值
- javascript - Jest ioredis mock - 将模拟绑定到模块
- c - waitpid() 总是返回 '-1'
- database - 我无法在 Apache NetBeans 12.3 上创建数据库
- python - Python 红黑树中的 TNULL
- flutter - 获取信息以在颤动中详细显示页面的最佳方法是什么?
- reactjs - 如何从内容原始数据中获取 RSS 提要的 html 元素(gatsby-plugin-feed)