OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Javascript Class in Functions with Same Name syntax. Without Argument [duplicate]

  • Thread starter Thread starter Droidbane
  • Start date Start date
D

Droidbane

Guest
Faulty Code

Code:
import tttt_data from "@/data/tttt.json";


export class TTT {

    getTTT() {
        return tttt_data.dersler;
    }

    getTTT(lesson) {
        return tttt_data.dersler[lesson];
    }

    getTTT(lesson, subject) {
        return tttt_data.dersler[lesson][subject];
    }
}

Error Code in Console

Code:
 getTTT(lesson, subject) {
> 15 |         return tttt_data.dersler[lesson][subject];
     |                                         ^       
  16 |     }
  17 | }

Starting Code

Code:
  const tttt = new TTT();
  const dersler = Object.keys(tttt.getTTTT());
  console.log(dersler);

When I not give an argument to the function, I want it to run without arguments. but the argument awaits. It does not work like in Java.

<p><strong>Faulty Code</strong></p>
<pre class="lang-js prettyprint-override"><code>import tttt_data from "@/data/tttt.json";


export class TTT {

getTTT() {
return tttt_data.dersler;
}

getTTT(lesson) {
return tttt_data.dersler[lesson];
}

getTTT(lesson, subject) {
return tttt_data.dersler[lesson][subject];
}
}
</code></pre>
<p><strong>Error Code in Console</strong></p>
<pre><code> getTTT(lesson, subject) {
> 15 | return tttt_data.dersler[lesson][subject];
| ^
16 | }
17 | }
</code></pre>
<p><strong>Starting Code</strong></p>
<pre class="lang-js prettyprint-override"><code> const tttt = new TTT();
const dersler = Object.keys(tttt.getTTTT());
console.log(dersler);
</code></pre>
<p>When I not give an argument to the function, I want it to run without arguments. but the argument awaits. It does not work like in Java.</p>
 

Latest posts

G
Replies
0
Views
1
Gamal Othman
G
Top