24h購物| | PChome| 登入
2012-04-14 08:44:00| 人氣318| 回應0 | 上一篇 | 下一篇

[JavaScript] Defining Functions

推薦 0 收藏 0 轉貼0 訂閱站台

var hello = function () {
  // Print hello on the console.
  console.log("i am saying hello");
};

hello();
hello();


var hi = function () {
  console.log("hi");
};

hi();

var myFirstFunction = function() {
    console.log("yourName");
}
myFirstFunction();

var fullName = "";
var name;
var firstLetter;
/*
   fixName function definition should go here.
*/
var fixName = function() {
    /***** Begin repeated code block *****/
    firstLetter = name.substring(0, 1);
    name = firstLetter.toUpperCase() + name.substring(1);
    fullName = fullName + " " + name;
    /***** End repeated code block *****/
}
name = prompt("Enter your first name (all in lower case):");
fixName();
name = prompt("Enter your second name (all in lower case):");
fixName();

console.log("And your full name is:" + fullName);

台長: Morris
人氣(318) | 回應(0)| 推薦 (0)| 收藏 (0)| 轉寄
全站分類: 不分類 | 個人分類: [學習]JavaScript |
此分類下一篇:[JavaScript] Variables in functions

是 (若未登入"個人新聞台帳號"則看不到回覆唷!)
* 請輸入識別碼:
請輸入圖片中算式的結果(可能為0) 
(有*為必填)
TOP
詳全文