Move the Point چالش 4 از جلسهی 13، متوسط
تابع move را بنویس. سه ورودی میگیرد: یک Point به اسم p و دو عدد dx و dy.
یک Point تازه برمیگرداند که x آن p.x + dx و y آن p.y + dy است. خود p نباید عوض شود.
برنامه باید 4 3 و بعد 1 1 را نشان بدهد.
<style>
body { font-family: sans-serif; text-align: center; padding: 16px; }
button, input, select { font-size: 16px; min-height: 40px; margin: 4px; }
#out { direction: ltr; text-align: left; font: 16px monospace; margin: 12px 0; padding: 12px; min-height: 28px; border-radius: 12px; background: #0f172a; color: #e2e8f0; white-space: pre-wrap; overflow-wrap: anywhere; }
#out .line { min-height: 22px; }
</style>
<pre id="out"></pre>
<script type="text/typescript">
interface Point {
x: number;
y: number;
}
// write the function move here
const a: Point = { x: 1, y: 1 };
const b: Point = move(a, 3, 2);
show(b.x, b.y);
show(a.x, a.y);
</script>
راهنما و جواب این چالش · برگشت به درس جلسهی 13: چیز در چیز · چالش بعدی: Find the Red Lines
بیشتر بخوان: جاوااسکریپت چیست؟ از دکمهی وب تا Node.js