js学習過程は忘れておきます
8241 ワード
var firstNameLength = 0; var firstName = "Ada"; firstNameLength =
firstName.length;
:firstNameLength = 8
var firstLetterOfFirstName = "";
var firstName = "Ada";
firstLetterOfFirstName = firstName[0];
firstLetterOfFirstName = A
function myFunction() {
console.log("Hi World");
}
myFunction();
関数名myFunctionによってFnction関数を呼び出すと、関数を呼び出すたびに、メッセージの「Hi World」が開発されたコンソールに印刷されます.すべての大かっこ間のコードは、関数の呼び出しごとに実行されます.function myFunction(a,b){
console.log(a+b);
}
myFunction(2,3);
ここのa、bはmyFunctionという関数のparametersで、2、3はmyFunctionという関数の参加であり、実際に参加することによって真の値を決める.function plusThree(num) {
return num + 3;
}
var answer = plusThree(5); // 8
plusThreeはnumというパラメータを持って、num+3に等しい値を返します.function myTest(val) {
var answer = "";
// Only change code below this line//
switch(val){
case 1:
answer="alpha";
break;
case 2:
answer="beta";
break;
case 3:
answer="gamma";
break;
case 4:
answer="delta";
break;
// defulat if/else else,case defulat //
defulat:
answer="nothing";
}
// Only change code above this line //
return answer;
}
caseが複数ある時function myTest(val) {
var answer = "";
// Only change code below this line
switch(val){
case 1:
case 2:
case 3:
answer = "Low";
break;
case 4:
case 5:
case 6:
answer = "Mid";
break;
case 7:
case 8:
case 9:
answer = "High";
break;
}
// Only change code above this line
return answer;
}
Count Change Cards
+1 2, 3, 4, 5, 6
0 7, 8, 9
-1 10, 'J', 'Q', 'K','A'
var count = 0;
function cc(card) {
// Only change code below this line
if (card <= 6) {
count++;
} else if (card <= 9) {
count += 0;
} else {
count--;
}
if (count <= 0){
return count + " Hold"; /* Return here */
} else {
return count + " Bet"; /* and here */
}
// Only change code above this line
}
// Setup
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};
function checkObj(checkProp) {
// Your Code Here
if (myObj.hasOwnProperty(checkProp)){
return myObj[checkProp];
}
return "Not Found";
}
// Test your code by modifying these values
checkObj("house");