Implementing Linear Search in JavaScript

AmitDiwan
Updated on 22-Jul-2020 07:48:36

450 Views

Following is the code for implementing linear search in JavaScript −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result,.sample {       font-size: 20px;       font-weight: 500;       color: blueviolet;    }    .sample{       color:red;    } Implementing linear search [1,19,5,11,22,55] CLICK HERE Click on the above button to search for 22 in the above array    let resEle = document.querySelector(".result");    let BtnEle = document.querySelector(".Btn");    let arr = [1,19,5,11,22,55];    BtnEle.addEventListener("click", () => {       for(let i=0;i

ES6 Property Shorthands in JavaScript

AmitDiwan
Updated on 22-Jul-2020 07:47:39

190 Views

In ES6, if the object key name and variables passed as properties value have same name then we can simply omit the value name and only specify the key name.Following is the code for property shorthands in JavaScript −Example Live Demo Document body {     font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result {       font-size: 20px;       font-weight: 500;       color: blueviolet;    } ES6 Property Shorthands in JavaScript CLICK HERE Click on the above ... Read More

Arithmetic Operations in Excel File Using OpenPyXL in Python

Pradeep Elance
Updated on 22-Jul-2020 07:45:19

422 Views

Python can help us use excel files directly from the python environment. We can refer to the each cell or a range of cells in excel and apply arithmetic operators on those cells. The results of those operations can also be stored at some cells whose location can be specified by the python program.In the below examples we are performing various arithmetic operations using inbuilt functions of excel. Like sum or average of numbers inside cells. The results are also stored at specific locations. We use the openpyxl module which opens a workbook and marks it active. Then we store ... Read More

Awaiting on Dynamic Imports in JavaScript

AmitDiwan
Updated on 22-Jul-2020 07:42:30

185 Views

Note − You will need a localhost server to run this example −Following is the code for dynamic imports in JavaScript −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result {       font-size: 18px;       font-weight: 500;       color: rebeccapurple;    } Awaiting on dynamic imports in JavaScript CLICK HERE Click on the above button to dynamically import modules    document.querySelector(".Btn").addEventListener("click", loadModule);    let resEle = document.querySelector(".result");    async function loadModule() {   ... Read More

Nesting Template Strings in JavaScript

AmitDiwan
Updated on 22-Jul-2020 07:40:39

594 Views

Following is the code for nesting template strings in JavaScript −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result {       font-size: 20px;       font-weight: 500;       color: blueviolet;    } Nesting template strings in JavaScript CLICK HERE Click on the above button to display the fullName using nested template string    let resEle = document.querySelector(".result");    let BtnEle = document.querySelector(".Btn");    function fullName(fName, lName) {       return fName + " " + lName;    }    let firstName = "Rohan";    let lastName = "Sharma";    BtnEle.addEventListener("click", () => {       resEle.innerHTML = `FirstName = ${firstName} and lastname = ${lastName} and       fullname = ${fullName(          `${firstName}`,          `${lastName}`       )}`;    }); OutputOn clicking the ‘CLICK HERE’ button −

Convert ISO 8601 String to DateTime Object in Android using Kotlin

Azhar
Updated on 21-Jul-2020 13:57:04

3K+ Views

This example demonstrates how to convert an ISO 8601 String to Date/Time object in Android using Kotlin.Step 1 − Create a new project in Android Studio, go to File? New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.Example Step 3 − Add the following code to src/MainActivity.ktimport android.os.Bundle import android.widget.TextView import androidx.appcompat.app.AppCompatActivity import java.text.SimpleDateFormat import java.util.* class MainActivity : AppCompatActivity() {    lateinit var textView: TextView    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       title = "KotlinApp" ... Read More

Change Background Color of ListView Items on Android using Kotlin

Azhar
Updated on 21-Jul-2020 13:50:02

581 Views

This example demonstrates how to change the background color of ListView items on Android.Step 1 − Create a new project in Android Studio, go to File? New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.Example Step 3 − Add the following code to src/MainActivity.ktimport android.os.Build import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.widget.ArrayAdapter import android.widget.ListView class MainActivity : AppCompatActivity() {    var operatingSystem: Array = arrayOf("Android", "IPhone", "WindowsMobile", "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X")    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main) ... Read More

Find Currently Running Applications Programmatically in Android Using Kotlin

Azhar
Updated on 21-Jul-2020 13:45:58

856 Views

This example demonstrates how to find the currently running applications programmatically in Android using Kotlin.Step 1 − Create a new project in Android Studio, go to File? New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.Example Step 3 − Add the following code to src/MainActivity.ktimport android.app.ActivityManager import android.app.ActivityManager.RunningTaskInfo import android.content.Context import android.os.Bundle import android.widget.TextView import androidx.appcompat.app.AppCompatActivity import java.util.* class MainActivity : AppCompatActivity() {    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       title = "KotlinApp"       val ... Read More

Remove Lines Between ListViews on Android using Kotlin

Azhar
Updated on 21-Jul-2020 13:42:16

201 Views

This example demonstrates how to remove lines between ListViews on Android using Kotlin.Step 1 − Create a new project in Android Studio, go to File? New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.Example Step 3 − Add the following code to src/MainActivity.ktimport android.os.Bundle import android.widget.ArrayAdapter import android.widget.ListView import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    lateinit var listView: ListView    var mobilePhones = arrayOf("Samsung", "Iphone", "Nokia", "Alcatel", "Blackberry", "Oppo", "Sony")    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)     ... Read More

Copy Text Programmatically in Android App using Kotlin

Azhar
Updated on 21-Jul-2020 13:38:36

464 Views

This example demonstrates how to copy text programmatically (Ctrl+C) in my Android app using Kotlin.Step 1 − Create a new project in Android Studio, go to File? New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.Example Step 3 − Add the following code to src/MainActivity.ktimport android.content.ClipData import android.content.ClipboardManager import android.content.Context import android.os.Bundle import android.view.View import android.widget.EditText import android.widget.TextView import android.widget.Toast import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    lateinit var editText: EditText    lateinit var textView: TextView    lateinit var clipboardManager: ClipboardManager   ... Read More

Advertisements