התקדמות שלך
39/47

ג'אווה סקריפט המדריך המלא 2024
אובייקטים תרגיל מספר 39 משחק מפלצות


בתרגיל ג'אווה סקריפט הבא נלמד איך לעבוד עם אובייקטים בצורה נכונה, איך ליצור פרופרטיז חדשים באובייקט ואיך לקרוא להם על מנת לחשב ערכים חדשים באותו האובייקט

  • 
    let monster = {
     skills: ["fire ball", "meteors", "ice attack"],
     isChallenging: true,
     hp: 3200,
     level: 10,
    };
                
  • a. write a function getSkills() that prints all monster skills.
  • b. Write a function hitMonster() that gets a monster and reduce its hp by 200 then print the current hp of the monster.
  • c. Write a function addUltimate() that gets a monster and add a new skill for it called "ulti power"
  • d. Write a function fightMonster() that prompts the user to enter his level, if his level is greater than monster level print "you are stronger" else print "you are weak".
שאלות
דברו איתי
whatsapp
ווצאפwhatsapp דיסקורדwhatsapp