TGViewer
Html and Css & Jsآموزش Html and Css & Jsآموزش @htmlcss_channels · 23.1K subscribers
Post #2407 1.43K
✅ JavaScript Practice Questions with Answers 💻⚡

🔍 Q1. How do you check if a number is even or odd?
✅ Answer:
let num = 10;
if (num % 2 === 0) {
console.log("Even");
} else {
console.log("Odd");
}


🔍 Q2. How do you reverse a string?
✅ Answer:
let text = "hello";
let reversedText = text.split("").reverse().join("");
console.log(reversedText); // Output: olleh


🔍 Q3. Write a function to find the factorial of a number.
✅ Answer:
function factorial(n) {
let result = 1;
for (let i = 1; i <= n; i++) {
result *= i;
}
return result;
}

console.log(factorial(5)); // Output: 120


🔍 Q4. How do you remove duplicates from an array?
✅ Answer:
let items = [1, 2, 2, 3, 4, 4];
let uniqueItems = [...new Set(items)];
console.log(uniqueItems);


🔍 Q5. Print numbers from 1 to 10 using a loop.
✅ Answer:
for (let i = 1; i <= 10; i++) {
console.log(i);
}


🔍 Q6. Check if a word is a palindrome.
✅ Answer:
let word = "madam";
let reversed = word.split("").reverse().join("");
if (word === reversed) {
console.log("Palindrome");
} else {
console.log("Not a palindrome");
}


💬 Tap ❤️ for more!


💎 @Htmlcss_channels | #css #JavaScript #HTML #interview
  • ❤ 4
More from @htmlcss_channels
  1. Sep 28, 2026🤖 خداحافظی با جستجوی خسته‌کننده منابع! اگه کار شما با گرافیک، تدوین یا هوش مصنوعی گره خور…
  2. Sep 28, 2026📚 آرشیو معتبرترین مجلات جهان 🆔 @EnglishMagazines_PDF ▪️▪️▪️▪️▪️▪️▪️▪️▪️ ⛳️ @Armisstab .
  3. Sep 28, 2026🤖 نسل جدید فیلترشکن‌های EASY2RAY با استفاده از هوش مصنوعی! 📱 اتصال بدون دردسر و بدون نیا…
  4. Sep 28, 2026؛CSS Clamp — اندازه‌گذاری هوشمند فرمول ساده ؛clamp(کمترین, مقدار_ایده‌آل, بیشترین) مثل یه…
  5. Sep 28, 2026🔅 CSS Clamp clamp(minimum, preferred, maximum); In this example, the preferred value is 5…
  6. Sep 26, 2026برای معرفی پروژه هاتون به کارفرما بهتره از این روش استفاده کنید این وبسایت پروژه هاتون رو…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →