What does んだもん mean and is used for?


I am currently studying for the JLPT N3 exam and I come across the following
rule that I don't really understand. **んだもん**

Although it is not identic, according to [this
link](http://jgram.org/pages/viewOne.php?tagE=mon) **~もん** is

> Used to reply dissatisfaction in very casual speech

Which kinds of makes a lot of sense according to the following example from
the book：

「どうして食べないの」「だって、まずいんだもん」 (日本語総まとめ N3 p.71)

"Why didn't you eat?" "Because it tastes awful."

However, I don't see how it applies to the following example:

今日の試験、できなかった...。勉強しなかったんだもん、仕方がない。

I didn't do well on the test today. I can't complain because I didn't study
much.

What is this rule actually used for and how does it take/make sense?

Extra information and links are welcomed

Thank you for your time.

Edit 1: Corrected the mistake mentionned.




Although んだ and もん are often used together, it's better to think of them as
two separate grammatical elements.

んだ is a colloquial version of のだ, and this の is known as **explanatory-の**.

  * [What is the meaning of ～んです/～のだ/etc?](https://japanese.stackexchange.com/q/5398/5010)
  * [Wasabi: Explanatory のだ （んだ）](https://www.wasabi-jpn.com/japanese-grammar/explanatory-noda/)

もん is a sentence-end particle that adds the nuance of "hey!", "come on!",
"listen!", "you know", "I mean it", etc. Note that this sounds childish. It's
used like so:

  * 見たもん！ (Hey,) I did see it!
  * 行くもん！ (I insist,) I'll go!
  * できるもん！ Come on, I can do it!

Put together, んだもん is used to emphatically describe a reason with emotion,
like "Come on, it's because ～", "You know, ...", etc.

