שאלה מראיון עבודה

jellymean

New member
שאלה מראיון עבודה

עניתי היטב על כמה שאלות אבל דוקא בשאלה הבאה הסתבכתי מעט.
נתנו קטע קוד ב-Javascript והיה צריך להפוך פונקציה אחת ל-Promise ואחת לממש. הנה שחזור של השאלה ואשמח לשמוע איך לפתור.

קוד:
function DataCache()
{

this.Cache = [];
	
/* write as a promise */
this.Save = 
function(key, value) {this.Cache[key] = value;}

/* implement - return true if key is in cache */
this.IsValid =

this.Retrieve = function(key)
{		
 if (this.IsValid(key))
  {
	return this.Cache[key];
  }

 return null;
 };
}
 
למעלה