OMDS Programming Questions, Cheat Sheet of Computer science

OMDS Programming Questions OMDS Programming Questions

Typology: Cheat Sheet

2021/2022

Uploaded on 08/29/2024

black-player-1
black-player-1 🇺🇸

1 document

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Problem: Given the Object below, find which kids like Basketball.
var obj = {
'John': {
'Age': 12,
'Hobbies': ['Computer Games', 'Football', 'Basketball'],
},
'Michael': {
'Age': 11,
'Hobbies': ['Basketball', 'Baseball']
},
'Sarah':{
'Age': 10,
'Hobbies': ['Reading Books', 'Dolls']
}
};
SOLUTION:
pf3

Partial preview of the text

Download OMDS Programming Questions and more Cheat Sheet Computer science in PDF only on Docsity!

Problem: Given the Object below, find which kids like Basketball. var obj = { 'John': { 'Age': 12 , 'Hobbies': ['Computer Games', 'Football', 'Basketball'], }, 'Michael': { 'Age': 11 , 'Hobbies': ['Basketball', 'Baseball'] }, 'Sarah':{ 'Age': 10 , 'Hobbies': ['Reading Books', 'Dolls'] } }; SOLUTION:

Problem: Create a function that checks whether 2 strings passed are anagrams.

Restrictions:

- Loops, recursions or any iterative solutions are prohibited

- Only check for alphanumeric characters

- Case insensitive

Sample:

// true console.log(checkAnagram('.', ',')); // true console.log(checkAnagram('Ba.sed!', 'da s_eb')); // false console.log(checkAnagram('2based1', 'sEd_ab')); // true console.log(checkAnagram('A decimal point', 'I’m a dot in place.')); // true console.log(checkAnagram('snooze alarms', 'Alas! No more Zs.')); function checkAnagram(string1, string2) { // do something here } Solution (JavaScript): Note:

  • Basic JavaScript methods used above should also be available to any widely used programming languages.