帮我解决这个java脚本教程问题: [英] Help me with this java script tutorial question:

查看:59
本文介绍了帮我解决这个java脚本教程问题:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述






问题:



使用console.log,在三个单独的行上打印出以下字符串的子字符串。



a。 bla bla

b。 墨尔本在墨尔本很棒(注意空间!)

c。 bla bla



请帮我完成任务b。

任务是使用单词/句子制作一个子串

墨尔本是:墨尔本很棒



墨尔本是.substring(0,12));



如何在句子中添加great这个词?





我是新来的编码。

英语不是我的母语。



Question:

Using console.log, on three separate lines, print out the substrings for the following strings.

a. bla bla
b. "Melbourne is" in "Melbourne is great" (note the space!)
c. bla bla

Please help me with task b.
The task is to make a substring with the word/sentence
"Melbourne is" to: "Melbourne is great"

"Melbourne is".substring(0,12) );

How do i add the word "great" to the sentence?


I am new to coding.
English is not my native language.

推荐答案

如果你渴望成为一名开发人员,那么学会使用那里的工具来帮助你。请参阅 http://www.w3schools.com/js/default.asp [ ^ ]。
If you aspire to be a developer then learn to use the tools that are there to help you. See http://www.w3schools.com/js/default.asp[^].


在JavaScript中,这样做完成由运营商+。



它的功能取决于操作数的类型。如果两者都是字符串,则返回连接,这是您需要的。如果只有一个操作数是字符串,则通过在其上调用 toString()将另一个操作数转换为字符串,然后将结果与另一个操作数连接。如果两者都不是字符串,则运算符执行其他操作(数字运算:-))。



类型是JavaScript中非常重要的概念,与许多其他技术:

https://developer.mozilla.org/ en-US / docs / Web / JavaScript / Data_structures [ ^ ],

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof [ ^ ]。



-SA
In JavaScript, this is done by the operator +.

It's function depends on the types of the operands. If both are strings, it returns concatenation, something you need. If only one of the operands is a string, another one is converted to a string by calling toString() on it and the result is then concatenated with another operand. If both are not strings, the operator does something else (number arithmetic :-)).

A type is a very non-trivial concept in JavaScript, very different from many other technologies:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures[^],
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof[^].

—SA


Quote:

在三个单独的行上使用console.log, 打印ou以下字符串的子字符串



a。 bla bla

b。 墨尔本在墨尔本很棒(注意空间!)

c。 bla bla

Using console.log, on three separate lines, print out the substrings for the following strings.

a. bla bla
b. "Melbourne is" in "Melbourne is great" (note the space!)
c. bla bla



当我读到这个问题时,这意味着你需要从字符串墨尔本很棒中提取墨尔本是部分,而不是添加它。



(当然可能是遗漏信息的情况,所以我完全错了。)



如上所述解决方案1,W3Schools是初学者的良好开端。

特别参见 JavaScript字符串方法 [ ^ ]


这篇关于帮我解决这个java脚本教程问题:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆