
Javascript String Concat Quiz
ကဲ... ဒီနေ့မှာတော့ JavaScript မှာ အခြေခံကျပြီး အရေးပါတဲ့ String concatenation နဲ့ပတ်သတ်တဲ့ Quiz လေးလုပ်ထားပါတယ်။ မိတ်ဆွေတို့အနေနဲ့ output ဘာထွက်မလဲ ဘာကြောင့်လဲဆိုတာလေးကို comment လေးရေးပြီးဖြေသွားပေးကြည့်ဦးဗျ။
Answer:
String Concatination ဆိုတာ programming ရဲ့ အရမ်းကိုအခြေခံကျတဲ့ concept လေးတစ်ခုပဲဖြစ်ပါတယ်။ Data type တွေထဲက မှ String Data type ဖြစ်တဲ့ double quote နဲ့ရေးထားတဲ့ စာလုံးလေးတွေကို plus operator နဲ့ပေါင်းလိုက်တဲ့ အခါမှာ string တစ်ခုအသစ်ရလာပါတယ်။ အဲ့တာကို string concatenate လုပ်တယ်လို့ခေါ်ပါတယ်။
ဥပမာ - str1 = "Hello";
str2 = "World";
result = str1 + " " + str2;
//Output: Hello World
ဒါဆိုရင် ပုံထဲက Quiz ရဲ့ အဖြေလေးကိုတစ်ချက်ကြည့်ရအောင်
1.console.log(6+6); //12

2.console.log("6"+"6"); // 66

3.console.log("6" + +6); // 66

4.console.log(6 + +"6"); //12

number နှစ်ခုပေါင်းတဲ့အခါ output 12 ကိုရပါတယ်။
5.console.log(6 + 6 - 6); //6

6.console.log("6" + "6" - "6"); // 60

ဘာလို့ဆို (-) က string concatinate မလုပ်ပေးပါဘူး။
အားလုံးကို number အဖြစ်ပဲ မြင်ပြီး numeric operation ကိုလုပ်ဆောင်လိုက်ခြင်းဖြစ်ပါတယ်။
မိတ်ဆွေတို့နားမလည်ရင်လည်း Codify Facebook Page chat box မှာအချိန်မရွေးလာမေးနိုင်ပါတယ်နော်။
Categories: Quiz
Login with your account to share your thoughts...
Comments
No comment yet.