0% found this document useful (0 votes)
7 views2 pages

SAI

Uploaded by

ankit.singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views2 pages

SAI

Uploaded by

ankit.singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

// Question - 1

Suppose we have
User:{
userId: id,
name: String,
age: number,
number: [numbers]
}

Write an API which takes userId as param and provides array numbers for those numbers which
are ending with 89
Example:
User:{
Number:[23489,23419,4599,3849,2488,23465489]
}

Response:[23489,23465489]

/numberEndingWith89
Get request : input : user_id

filteredUser = user.filter( (i) => i.userId == id )

Numbers = filteredUser.number

For (i = 0; i< Numbers.length(): i++) {


n = numbers[i]
sample Number = N % 100

If (sampleNumberr == 89) {
arr.push(n)
}

Return arr
// Question - 2

Suppose we have
User:{
userId: id,
name: String,
age: number,
number: [String]
}

Write an API which takes userId as param and provides array numbers for those numbers which
are ending with 89
Example:
User:{
Number:[‘23489’,’23419’,4599,3849,2488,23465489] // these are strings
}

Response:[23489,23465489]

Const constEigght = ‘8’


Const constNine = ‘9’
/numberEndingWith89
Get request : input : user_id

filteredUser = user.filter( (i) => i.userId == id )

Numbers = filteredUser.number

For (i = 0; i< Numbers.length(): i++) {


n = numbers[i]
Length = n.length() ;
if(length < 2 ) continue
If ( n[length-1] === constNine && n[length-2] === contEitht] {
arr.push(n)
}
}

Return arr

You might also like