GoConqr has a new look! Let us know what you think.

Module 16 of 22 · Media

Write to a file

Kostas Diakogiannis

Write to a file

Writing to a file

Now it is time to write to a file. 

We will create a string variable with some text of our choice, and we will try to write the content of this text into an empty file. 

First let's remove the previous content from the .txt file. Then after creating the text inside our script we will use the writeFileSync function to write to a file synchronously as it is shown above. When the operation is finished, we can check the content's of the .txt file by opening it. It should have the text you have defined. 

A massive success!!

Instructions

You must submit an attempt for this quiz to progress. You can submit it after the last question.

Go to the chosen module

Feedback

What is it about?

What do you think of the new look?

How do you like it?