---
# System prepended metadata

title: 23T3 07B

---

```javascript=

// findVowels.test.ts 
describe('Error cases', () => {
    test.each([
        {
            testcase: 'upper case letter',
            input: 'ABC'
        },
        {
            testcase: 'upper case and lower case letter',
            input: 'ABCabc'
        },
        {
            testcase: 'special characters',
            input: '%'
        },
    ])("error case $# with test name '$testcase'" ({testcase, input}) => {
        expect(findVowels(input).toThrow(Error) }
    })
  ('error %i', (input) => {
    expect(findVowels(input).toEqual({ error: expect.any(string) }
    (1)));  
   })

});

describe('Success cases', () => {
    test.each(['aeiou', ], [''])
    (input, expected) => {
        expect(findVowels(input)).toBe(expected)
});

// findVowels.ts -- implementation
export const findVowels = (message: string) => { 
  if (/[^a-z ]/.test(message)) {
      throw new Error(`input ${message} did not conform to lowercase characters and spaces format`);
  };
  
//   const res = {};
//   for (const vowel of 'aeiou') res[vowel] = 0;

//   message.forEach(letter => switch (letter) {
//     case "a": res[a]++;
//     case "e": res[e]++;
//     case "i": res[i]++;
//     case "o": res[o]++;
//     case "u": res[u]++;           
//   });
    
  const countVowels = (char: string) => (message.match(new RegExp(char, 'g')) || []).length

  return  {
      a: countVowels('a'),
      e: countVowels('e'),
      i: countVowels('i'),
      o: countVowels('o'),
      u: countVowels('u'),
  };
};

// main.ts -- use try/catch block
import promptSync from 'prompt-sync';
import { findVowels } from './vowels';

const prompt = promptSync();

let input: string;
while ((input = prompt('Enter message: '))) {
    try {
      console.log(findVowels(input));
    } catch (err) {
      console.log(err.message);
    }
}






```


     .-"-.
           : /"\ :
           `.`-'.'
             | |
          _..| |.._
     _  ."   ___   ".  _
    : `: .-""   ""-. :' :
    `  : : ()   () : :  '
     `.` `   ___   ' '.'
        `-`._____.'-'
        .-"       "-.
      ."             ".
    .'  .^         `.  `.
  ."  .".'          `".  "
 `   ' .    _______  ` ".  "._
`_.-'      :       :  `  "._  )
      .    :       :   .    `"
      .    '-------'
       .                '
        .       _      :
        :     .' `.    :
        :    .     .   :
        :   .          :
        :___.       .__:
       (____)       (___) mh
       
       
┊┊ ☆┊┊┊┊☆┊┊☆ ┊┊┊┊┊
┈┈┈┈╭━━━━━━╮┊☆ ┊┊
┈☆ ┈┈┃╳╳╳▕╲▂▂╱▏┊┊
┈┈☆ ┈┃╳╳╳▕▏▍▕▍▏┊┊
┈┈╰━┫╳╳╳▕▏╰┻╯▏┊┊
☆ ┈┈┈┃╳╳╳╳╲▂▂╱┊┊┊
┊┊☆┊╰┳┳━━┳┳╯┊ ┊ ☆┊

Firstly, it is criminal that some people  are even allowed to enter DESN1000. These people are so technically and intellectually inept that it ruins the experience of anyone mildly competent in this course. I understand UNSW is looking to remove money from these people's pockets, to which I have no objection as they have wasted my own time, but I would be very appreciative in future if UNSW would herd these morons into their own groups where they are all able to indulge in their excessive laziness and stupidity. That way, at the very least I could feel as part of "a learning community", rather than a small group of animals. I use the word "animal" here, as it efficiently captures the primary characteristics of animals, those being: inability to communicate, lack of organisation, lack of skills, lack of intelligence, lack of work ethic, lack of self-awareness. I can call them animals as their IQ is clearly well below what is considered anatomically human. One of these animals literally cannot spell better than someone in kindergarten. Yet UNSW expects me to write reports as a part of group work with this animal? If he cannot spell properly how am I expected to accept that his written work is able to attain even the lowest criteria on the rubric. Already it is obvious that just by this animal's mere presence in the group his entire workload has to become my responsibility in order for an acceptable mark to be acquired. real
![](https://hackmd.io/_uploads/ry_dhXLG6.png)
