In t his example we present a number guessing game Example(s) function guessNumber() { // generating a random integer from 1 to 5 const random = Math.floor(Math.random() * 5) …
Programs
-
-
In this article we show you a program that will simulate the shuffling of a deck of cards Code (function () { var cardWeights = [“1”, “2”, “3”, …
-
In this example we compare 2 dates in C# Example We store a date in a variable and for the purpose of this example we add 30 days We then …
-
In this example we show you a way to count the amount of lines in a string Example We use a while loop to count the lines in string. We …
-
In this example we show you how to replace a string in another string in C# Example The Replace() function is used to change the word. It changes all occurrences …
-
In this example we will read the contents of a file in C# Example The ‘StreamReader’ is used to position the file pointer at the beginning of the file. We …
-
In this example we show copy the contents of one file into another in C# Example This example will take a file called testfile.txt and copy the contents to a …
-
In this example we will show how to get the time when a file was created, last accessed and last written to in C# Example We get the date and …
-
In this example we show how to create a new directory in C# Example The new Directory is created on the J drive directory using the CreateDirectory() function. You may …
-
In this example we list all of the files in a directory in C# Example You need to change the directory – J:\csharp\basics The files in the directory are printed …