This is so simple that I can't understand it - DigitalWrite

For some reason I can't wrap my head around the examples given....

Description:
Reads the value from a specified digital pin, either
HIGH or LOW.

Syntax:
digitalRead(pin)

Parameters:
pin:- the number of the digital pin you want to read (int)

Returns:
HIGH or LOW

Example:
Sets pin 13 to the same value as pin 7, declared as an input.
int ledPin = 13; //LED connected to digital pin 13
int inPin = 7; //push button connected to digital pin 7
int val = 0; //variable to store the read value

Could someone give me a bit of assistance.....not with the way DigitalWrite works....but withthe examples given...... or maybe it goes hand in hand?

Thanks

Please use code tags (</> button on the toolbar) when you post code or warning/error messages. The reason is that the forum software can interpret parts of your code as markup, leading to confusion, wasted time, and a reduced chance for you to get help with your problem. This will also make it easier to read your code and to copy it to the IDE or editor. If your browser doesn’t show the posting toolbar then you can just manually add the code tags:
[code]``[color=blue]// your code is here[/color]``[/code]
Using code tags and other important information is explained in the How to use this forum post. Please read it.

That is the reference page for digitalRead(). If you want to know about digitalWrite() (as indicated by the subject of your post) I recommend you look at the digitalWrite() reference page:
https://www.arduino.cc/reference/en/language/functions/digital-io/digitalwrite/
Also study the example sketch File > Examples > 01.Digital > Blink and the associated tutorial:

After spending some time with those resources if you still don’t understand please come back here with specific questions.

What is hard? Read the state of ‘inPin’, store the state in ‘val’, and write that state to ‘ledPin’. Repeat.
The state of ‘inPin’ is HIGH if the voltage is close to 5V and LOW if the voltage is close to 0V.

int ledPin = 13; // LED connected to digital pin 13
int inPin = 7; // pushbutton connected to digital pin 7
int val = 0; // variable to store the read value

void setup()
{
 pinMode(ledPin, OUTPUT); // sets the digital pin 13 as output
 pinMode(inPin, INPUT); // sets the digital pin 7 as input
}

void loop()
{
 val = digitalRead(inPin); // read the input pin
 digitalWrite(ledPin, val); // sets the LED to the button's value
}