Chapter 2: Calculations and Strings
الشابتر ٢: الحسابات والنصوص
1. Print with console.log١. الطباعة بـ console.log
console.log(...) prints what is inside the brackets on the screen. Text goes between double quotes. End the line with ;الأمر console.log بيطبع على الشاشة اللي جوه القوسين. الكلام بين تنصيص " ". وفي آخر السطر ; يعني خلصت الأمر.
console.log("Hello");Hello
2. Text or calculation?٢. نص ولا حساب؟
A string is text and needs quotes. A calculation has no quotes: the computer calculates it.الـ string يعني نص ولازم بين تنصيص. الحساب من غير تنصيص والكمبيوتر بيحسبه.
console.log("1+1");
console.log(1+1);1+1 2
Remember: words in quotes, calculations without quotes.افتكر: الكلام بتنصيص والحساب من غير تنصيص.
3. Operators٣. علامات الحساب
+ add, - subtract, * multiply (star), / divide (slash).+ جمع، - طرح، * ضرب (نجمة)، / قسمة (شرطة مايلة).
console.log(432+345); console.log(100-50); console.log(5*9); console.log(10/2);
777 50 45 5
Careful: multiply is * not x, divide is / not ÷.خد بالك: الضرب نجمة * مش x، والقسمة / مش ÷.
4. Text + calculation in one line٤. كلام + حساب في سطر واحد
Join with +. Put the calculation in parentheses ( ). Keep the space inside the quotes.بنوصّلهم بعلامة +. الحساب بين أقواس ( ). وخلي المسافة جوه التنصيص.
console.log("Set of 2 coffees " + (250 * 2) + " codycoins");Set of 2 coffees 500 codycoins
Common mistakes: calculation inside quotes, no space inside quotes, missing parentheses or ;أخطاء شائعة: الحساب بين تنصيص، نسيان المسافة، نسيان القوس أو ;