-
Code export interface iType{ id: number, name: string, } const datas: iType[] = [ { id: 1, name: "Manny" }, { id: 2, name: "Danny" }, { id: 3, name: "Socciella" }, ]; export function findData ( data: iType[],selectedData: number): iType | undefined { return data.find(item => item.id === selectedData); } findData(datas,1); findData(datas,2);
Test Cases // See https://www.chaijs.com for how to use Chai. import { assert } from "chai"; import { findData, iType } from "./solution"; const data: iType[] = [ { id: 1, name: "Manny" }, { id: 2, name: "Danny" }, { id: 3, name: "Socciella" }, ]; // TODO Add your tests here describe("Checking Test Nagatech Basic 3", function() { it("Status", function() { assert.strictEqual(findData(data, 1), data[0]); assert.strictEqual(findData(data, 2), data[1]); }); });
Output:
-
Code - export interface iType{
id: number,name: string,}export function findData (data: iType[], selectedData: number): iType {// You Can Code Here- id: number,
- name: string,
- }
}- const datas: iType[] = [
- {
- id: 1,
- name: "Manny"
- },
- {
- id: 2,
- name: "Danny"
- },
- {
- id: 3,
- name: "Socciella"
- },
- ];
- export function findData ( data: iType[],selectedData: number): iType | undefined {
- return data.find(item => item.id === selectedData);
- }
- findData(datas,1);
- findData(datas,2);
- All
- {{group.name}} ({{group.count}})
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}