Programming Basics SQL HTML CSS JavaScript React Python C++ Java JavaFX Swing Problem Solving English English Conversations Computer Fundamentals Linux Learn Typing

محرر الكود ينفذ ما بداخل جملة الشرط رغم أن الشرط لم يتحقق!

في درس الشروط المتداخلة في دورة أساسيات البرمجة، في الحل الأول، إذا أدخل المستخدم الرقم 0 في إجابته على عدد سنوات الخبرة، فإن محرر الكود ينفذ ما بداخل جملة الشرط if(experience >=1) رغم أن الشرط لم يتحقق.

var experience;
var is_married;

write("Enter years of experience : ");
experience = read();

write("Are you married (yes/no): ");
is_married = read();

if(experience >= 1)
{
  if(is_married == "yes")
  {
    write("Your salary is 1000 per month.");
  }
  else if(is_married == "no")
  {
    write("Your salary is 800 per month.");
  }
  else
  {
    write("To answer write \"yes\" or \"no\"");
  }   
}
else 
{
  write("You dont have one year experience.");
}

النتيجة

Enter years of experience : 0
Are you married (yes/no): no
You dont have one year experience.
Done Execution

فما معنى ذلك؟

تعليقات 1

أضف تعليق

يجب تسجيل الدخول حتى تتمكن من إضافة تعليق أو رد.