What is my goal | Objectives when mining?
Basically, you are solving a puzzle. A puzzle is to come with a nounce(number) which when added with the block header and hashed, hash should start with some number of zeros.

Higher the number of zeros, difficult it is to come with the nouce for the given block header. According to the current hash power in the network, network adjusts the difficulty.

Implementation would look something like this:
1) Generate block header for the given set of transactions 
2) Get the current network difficulty level ( number of zeros hash should start with )
3) Plug in random numbers so that : hash( nounce + blockheader ) starts with given number of zeros
4) Form a block and include nounce in the blockheader ( So that other node can verify your work )