Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <!DOCTYPE html>
<html>

<head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Learning JavaScript</title>
    <link href="./style.css" rel="stylesheet" />
</head>

<body>
    <h1>
        JS Loops, Basic Algorithm Challenges
    </h1>
    <img src="https://thelead-758c.kxcdn.com/wp-content/uploads/2019/06/javascript-illustration.png" />
    <div id="div">
        <p>
            Today we are going to get familiar with Javascript arrays and loops
        </p>
        <p>
            In this first introduction session, we will go through the following concepts and topics.
        </p>
        <ul>
            <li>Learn how to store data ub JS in arrays</li>
            <li>Array property and methods</li>
            <li>Learn how to write automated loops in JS</li>
            <li>For loops</li>
            <li>Nested loops</li>
            <li>Higher order functions</li>
            <li>Iterators (forEach, Map, Filter)</li>
        </ul>
    </div>


    <!--  Connecting to javascript file  -->
    <script src="./index.js">
    </script>
</body>

</html>
              
            
!

CSS

              
                body {
    background: ;
}
img {
    margin-left: 15%;
    width: 70%;
    height: 400px;
}
div {
    margin-top: 20px;
    margin-left: 30%;
    margin-right: 30%;
}
h1 {
    text-align: center;
}
              
            
!

JS

              
                // var studentArr = ["deric", "adrian", "boon chuan", "rizqin"]

// console.log(studentArr[0])
// console.log(studentArr[2])
// console.log(studentArr[studentArr.length - 1])
// console.log(studentArr[(studentArr.length - 1) - 2])


// var arr1 = [1,2,3,4,5]
// arr1.push(6)
// console.log(arr1)

// arr1 = [1,2,3,4,5]
// arr1.pop()
// console.log(arr1)

// arr1 = [1,2,3,4,5]
// arr1.unshift(0)
// console.log(arr1)

// arr1 = [1,2,3,4,5]
// arr1.shift()
// console.log(arr1)

// console.log(arr1.length)
// // ----------------------------------------

// var studentArr = ["deric", "adrian", "boon chuan", "rizqin"]

// for(let i = 0; i < studentArr.length; i++){//i = i + 1

//     console.log(i, studentArr[i])

// }

// var newArr = []

// for(let i = 0; i < 5; i++){
//     newArr.push(i + 1)
// }

// for(let i = 5; i > 0; i--){
//     newArr.push(i)
// }

// console.log(newArr)

// // ----------------------------------------
// var arr = [ [1,2], [3,4], [5,6,7] ]

// let prod = 1

// for(let i = 0; i < arr.length; i++){//i = i + 1

//     for(let j = 0; j < arr[i].length; j++){//j = j + 1

//         console.log(arr[i][j])
//         prod = prod * arr[i][j]
        
//     }

// }

// console.log(prod)

// // ----------------------------------------

// var studentArr = ["deric", "adrian", "boon chuan", "rizqin"]

// studentArr.forEach(function(item){

//     console.log(item)

// })

// // studentArr.forEach(item => {

// //     console.log(item)

// // })

// // ----------------------------------------

// let newstudentArr = studentArr.map(item => {

//     return item.toUpperCase() + '!!!'

// })

// // let newstudentArr = studentArr.map(function(item){

// //     return item.toUpperCase() + '!!!'

// // })
// // ----------------------------------------

// let newstudentArr = studentArr.filter(function(item){

//     return item.length == 6

// })

// // let newstudentArr = studentArr.filter(item => {

// //     return item.length == 6

// // })

// console.log(studentArr)
// console.log(newstudentArr)
// // ----------------------------------------

// var Arr = ['logan','deric','pizza',1,2,true,false]

// let newArr = Arr.filter(item => {
//     return typeof(item) == 'boolean'
// })

// console.log(newArr)
// // ----------------------------------------

// let newArr = []
// for(let i = 0; i < Arr.length; i++){

//     if(typeof(Arr[i]) == 'boolean'){
//         newArr.push(Arr[i])
//     }

// }
// // ----------------------------------------

// let newArr = [1,2,3,4,5,6,7,8,9,10]

// let outArr = []
// for(let i = 0; i < newArr.length; i++){

//     outArr.push(newArr[i] * newArr[i])

// }
// // ----------------------------------------

// let outArr = newArr.map(item => {

//     return item * item

// })
// // ----------------------------------------

// let outArr = []
// for(let i = 0; i < newArr.length; i++){

//     if( newArr[i] % 2 == 0 ){

//         outArr.push(newArr[i] * newArr[i])

//     }else{

//         outArr.push(newArr[i])

//     }
// }

// console.log(outArr)
              
            
!
999px

Console