javascript 练习Javascript基本变量

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript 练习Javascript基本变量相关的知识,希望对你有一定的参考价值。

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Practice JavaScript Variables</title>
  <script type="text/javascript" src="practice.js"></script>
</head>
<body>

</body>
</html>
// 1. Attach this file -- practice.js -- to the index.html file using a <script> tag
// 2. In this JavaScript file, add a prompt dialog to capture input from the user and store it in a variable
// 3. Add a second a prompt dialog to capture input from the user and store it in a second variable
// 4. Create a third variable and which combines an uppercase version values in the two other variables separated by a space. For example, if the first two variables contain "sally" and "forth", this third variable should contain the string value "SALLY FORTH"
// 5. Create a fourth variable to store a number. The number should be the total number of characters in the third variable. 
// 6. Add an alert dialog box that says "The string '[insert value of third variable here]' is X number of characters long." For example, if the third variable contained the string "SALLY FORTH" then the alert dialog should says "The string 'SALLY FORTH' is 11 characters long."

var arg1 = prompt("Type anything.");
var arg2 = prompt("Type otherthing.")

var message_upper = arg1.toUpperCase() + " " + arg2.toUpperCase()
var lenght_message = message_upper.length

alert("The string " + message_upper + " is " + lenght_message + " number of characters long.")

以上是关于javascript 练习Javascript基本变量的主要内容,如果未能解决你的问题,请参考以下文章

JavaScript专项练习1 [牛客]

JavaScript之基本函数

基础JavaScript练习总结

javascript练习题函数

JavaScript:递归计数基本案例

慕课网javascript 进阶篇 第十章 编程练习