Hints and Tips on Learning Javascript

Here are some Javascript hints/tips that i have come across when learning to program Javascript and i thought to share them with you.

Small little javascript snippets that will enhance your big Javascript applications as a Javascript programmer.

Javascript Code example 1)...

Check if a string is uppercase

const isUpperCase = str => str === str.toUpperCase();

console.log(isUppercase("string")); //false

console.log(isUppercase("STRING")); //true

console.log(isUppercase("5TR1NG")); //true

Javascript code processing as zeros and zero

Javascript Code example 2)...

Finds the differences between arrays

const differenceInArrays = (array1, array2) => {

    const set = new Set(array2);

    return array1.filter(x => !set.has(x));

};

differenceInArrays(["apple", "orange", "grape"], ["apple", "orange", "pear"]);

// ["grape"]

differenceInArrays([8, 13, 7],[ 25, 8, 9]);

// [13, 7]

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Javascript code processing as zeros and zero

Javascript Code example 3)...

Scrolls to the top of the page

const scrollToTopOfPage = ( ) => {

    const c = document.documentElement.scrollTop | | document.body.scrollTop;

    if (c > 0 {

        window.requestAnimationFrame(scrollToTop);

        window.scrollTop(0, c - c / 8);

    }

};

scrollToTopOfPage();

Hints & Tips on Learning Linux (FILES).

Linux logo on fmssltd.co.uk

Here are some Linux hints/tips that i have come across when learning to use Linux and i thought to share them with you.

These small little Linux command snippets that will enhance your use of the Linux command set.

Linux Code example 1)...

Display the manual for a Linux command

If you are unsure of the Linux Command you want to use or the options it offers, typing man then the command displays a manual for that command within Linux itself

Linux Terminal header bar on fmssltd.co.uk

root@fmssltd:~/home/user$ man ls

                 User Commands

NAME

      ls - list directory contents

SYNOPSIS

      ls [OPTION]... [FILE]...

DESCRIPTION

      List information about the FILEs (the current directory by default). Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.

Linux Code example 2)...

Display the Present working directory

Don't know where you are in the Linux directory structure typing pwd

displays the current working directory for you.

Linux Terminal header bar on fmssltd.co.uk

root@fmssltd:~/home/user$ pwd

/home/user/desktop/pictures

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Linux Code example 3)...

List the contents of the current directory

Want to know what files or directories are in the directory you are in, typing ls, displays a list of files & directories for you.

Linux Terminal header bar on fmssltd.co.uk

root@fmssltd:~/home/user$ ls

Holidays   Kids   adam.jpg   ben.jpg

Holidays & Kids = directories. adam.jpg & ben.jpg = jpeg images.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Linux Code example 4)...

Change to another directory

You want to work in another directory, just typing cd with a directory after it, moves you to that directory. If the directory does not exist first check for a misspelling or use the ls command.

Linux Terminal header bar on fmssltd.co.uk

root@fmssltd:~/home/user$ cd Holidays

root@fmssltd:~/home/user/Holidays$

Random 3
Book 3

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Python Code example 2)...

Partition a list into number of groups

listgroups.py

mylist = [‘Moon’, ‘Trees’, ‘Monkeys’, ‘Humans’, ‘Black’, ‘White’]

groups = list(zip(*[iter(mylist)]*2))

print (groups)

Python 3.8.0 (v3.8.0:fa919fdf25, Oct 14 2019, 10:23:27)

Type "help", "copyright", "credits" or "license()" for more information.

>>>$ python listgroups.py

[('Moon', 'Trees'), ('Monkeys', 'Humans'), ('Black', 'White')]

>>>

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Python Code example 3)...

Hints & Tips on Learning Python (Strings).

Python Logo

Here are some Python hints/tips that i have come across when learning to program Python and i thought to share them with you.

These small little Python code snippets that will enhance your bigger Python applications as you grow as a Python programmer.

Python Code example 1)...

Take the a string as input and covert it into a list

stringtolist.py

print("Enter a string of data?")

my_list = list(map(int, input().split()))

print(my_list)

Python 3.7.5 (v3.7.5:5c02a39a0b, Oct 14 2019, 18:49:57)

Type "help", "copyright", "credits" or "license()" for more information.

>>>

Enter a string of data?

10 20 30 40 50

[10, 20, 30, 40, 50]

>>>

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Python Code example 2)...

Python string formatting

The following example summarises the ‘f’ string formatting option in Python 3.

Since Python 3.0, the format() function was introduced to provide advance formatting options.

Python f-strings are available since Python 3.6. The string has the f prefix and uses { } to evaluate variables.

format_string.py

name = ‘Andrew’

age = 51

print (f'{name} is {age} years old')

Python 3.7.5 (v3.7.5:5c02a39a0b, Oct 14 2019, 18:49:57)

Type "help", "copyright", "credits" or "license()" for more information.

>>>$ python format_string.py

Andrew is 51 years old

>>>

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Python Code example 3)...

The hints and tips are provided to help you better use your computer equipment and improve your productivity.

These hints and tips are the accumulation of many years experience of dealing with the general public and business IT equipment user's.

They have been written to be easy to understand and break down the jargon that is indoctrinated in IT equipment article's, book's and publication's.

I hope you enjoy these hints and tips and find them useful.

 
 

Subcategories

Provides Help to common computer/tablet and web problems.