View main.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
List<num> numList = [5,8,9,6,4]; | |
numList.forEach((x) => print (x * x)); | |
} |
View main.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
String name = 'Steph Crown'; | |
for (var j in name) { | |
print(name); | |
} | |
} |
View main.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
String name = 'Steph Crown'; | |
for (var j in name.split('')) { | |
print(j); | |
} | |
} |
View main.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main(){ | |
String name = 'Steph Crown'; | |
int counter = 0; | |
while (counter < name.length) { | |
print(name[counter]); | |
++counter; | |
} | |
} |
View palindrome checker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///A palindrome checker | |
bool checkPalindrome(String str) { | |
return str == reverseStr(str); | |
} | |
///A string reverser | |
String reverseStr(String str) { | |
return str.split('').reversed.join(); | |
} |
View main.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///A palindrome checker | |
bool checkPalindrome(String str) { | |
return str == reverseStr(str); | |
} | |
///A string reverser | |
String reverseStr(String str) { | |
return str.split('').reversed.join(); | |
} |
View main.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///A function that checks if a list is a subset of another | |
bool subsetChecker(List list1, List list2) { | |
//Iterates through first array and checks if all element are in second array | |
return list1.every((item) => list2.contains(item)); | |
} | |
void main() { | |
View main.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///Checks if a number is prime | |
bool checkPrime(x) { | |
int factors = 0; | |
int i = 1; | |
//He number of factors of the number | |
while (i <= x) { | |
factors = x % i == 0 ? factors + 1 : factors; | |
i++; | |
} |
View index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Checks if we can use serviceWorker. | |
if ("serviceWorker" in navigator) { | |
navigator.serviceWorker | |
.register("sw.js") | |
.then((registration) => { | |
// The registration wass successful | |
console.log("Service worker registered"); | |
console.log(registration); | |
}) |
View sw.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Listens to an install event | |
self.addEventListener("install", (event) => { | |
event.waitUntil( | |
// We try to open a cache named "assets". | |
// If it does not exist, a new one will be created and named "assets" | |
caches.open("assets").then((cache) => { | |
// Add an array of path to files you want to add to cache | |
return cache.addAll([ | |
"./", | |
"./css/index.css", |
OlderNewer